Foswiki on GitHub is open for business! Next release meeting: Monday October 13, 1300Z

Item11045: TOC doesn't remove manual links properly

Priority: CurrentState: AppliesTo: Component: WaitingFor:
Normal Closed Engine    
Test case:

%TOC%

<noautolink>
---++ headline <a href="#" class=" FooBar "> click me </a>
</noautolink>

Result is something like this:

Problem is that the TOC clean-up code generates <nop>s inside a <a href..../a> which then hinders the rest to be cleaned up properly.

Current patch:

--- lib/Foswiki/Macros/TOC.pm   (revision 12289)
+++ lib/Foswiki/Macros/TOC.pm   (working copy)
@@ -178,6 +178,9 @@
         $text =~ s/(^|[\s\(])=+([^\s]+?|[^\s].*?[^\s])=+
                    ($|[\s\,\.\;\:\!\?\)])/$1$2$3/gx;
 
+        # Prevent manual links
+        $text =~ s/<[\/]?a\b[^>]*>//gi;
+
         # Prevent WikiLinks
         $text =~ s/\[\[.*?\]\[(.*?)\]\]/$1/g;    # '[[...][...]]'
         $text =~ s/\[\[(.*?)\]\]/$1/ge;          # '[[...]]'
@@ -190,9 +193,6 @@
         $text =~ s/(^|[\s\-\*\(])
                    ([$Foswiki::regex{mixedAlphaNum}]+\:)/$1<nop>$2/gox;
 
-        # Prevent manual links
-        $text =~ s/<[\/]?a\b[^>]*>//gi;
-
         # Prevent duplicating id attributes 
         $text =~ s/id=["'][^"']*?["']//gi;

Needs a test case covering this as well as further checks that the other unit tests still pass ...

-- MichaelDaum - 16 Aug 2011

Item11137 has been marked a dupplicate of this report

-- MichaelDaum - 20 Sep 2011
 

ItemTemplate edit

Summary TOC doesn't remove manual links properly
ReportedBy MichaelDaum
Codebase 1.1.3, trunk
SVN Range
AppliesTo Engine
Component
Priority Normal
CurrentState Closed
WaitingFor
Checkins distro:f412157d30d7 distro:cd3eed5ea185
TargetRelease patch
ReleasedIn 1.1.4
Topic revision: r6 - 17 Dec 2011, GeorgeClark
 
The copyright of the content on this website is held by the contributing authors, except where stated elsewhere. see CopyrightStatement. Creative Commons License