cross
New Foswiki release 2.1.6 is available with important security fixes.
Sourceforge foswiki email lists being discontinued. Subscribe to the new Foswiki announce and discuss lists at MailingLists
You are here: Foswiki>Tasks Web>Item11045 (17 Dec 2011, GeorgeClark)Edit Attach

Item11045: TOC doesn't remove manual links properly

pencil
Priority: Normal
Current State: Closed
Released In: 1.1.4
Target Release: patch
Applies To: Engine
Component:
Branches:
Reported By: MichaelDaum
Waiting For:
Last Change By: GeorgeClark
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 - This page was cached on 01 May 2018 - 22:16.

The copyright of the content on this website is held by the contributing authors, except where stated elsewhere. See Copyright Statement. Creative Commons License