Download & Extend

Preserving HTML header attributes is causing side-effects.

Project:Table of Contents
Version:6.x-3.5
Component:Code
Category:bug report
Priority:normal
Assigned:Unassigned
Status:closed (fixed)

Issue Summary

I have some header tags that incorporate href tag to link to the detailed version of the content. When the new TOC stuff runs, the HTML attributes are being preserved, so the TOC links do not appropriate index within the current URL.

The TOC is pointing to the inner most href:

  • Title
  • Shouldn't all href attributes be filtered out.?.? If not, can you give me some insight for where to incorporate this type of filtering locally.

    Comments

    #1

    Whoops, here is the HTML again:

    <li class="toc-level-1"><a href="#HelloTitle"><a href="/drupal6/content/hellotitle" title="HelloTitle">HelloTitle</a></a></li>

    #2

    Status:active» needs review

    OK, I integrated PHP's 'strip_tags()' function in two places in the attached patch. I'm not sure if anyone would want this filtering to be configurable or not.

    AttachmentSize
    tableofcontents.pages_.inc_.diff 965 bytes

    #3

    Stacy,

    I'm thinking that a strip_tags() by itself may be a bit too drastic. Should we allow all tags except <a> tags?

    That means if you have elements such as <em> and <strong> they would stay. We could also allow the user to enter the list of tags he/she wants to keep.

    Thank you for the patch!
    Alexis Wilke

    #5

    Stacy,

    You have to be careful no Drupal and write &lt; when you want to include a < character. 8-)

    No time this week, but since you already have working solution for your site I suppose you can wait some time to get an official version.

    Thank you.
    Alexis

    #6

    Hello,

    me too having the same problem experienced by Stacy, some headers in the page contain href links which remain in TOC output, this causing items to be unusable.

    Do you have any news by chance? Thank you

    zoo

    #7

    zoo,

    There is actually a fix for that problem in the -dev version. It includes code to remove any anchor from the title in the TOC itself. Are you using version 3.1?

    Thank you.
    Alexis

    #8

    Hello AlexisWilke,

    Yes, I am using the 3.1.

    I had solved by hacking the core module with the "tableofcontents.pages_.inc_.diff" (Stacy, above).

    But now I will try the dev version of the module you suggested. Thank You!

    zoo

    #9

    Let me know if the -dev worked for you. If so, I could do a 3.2 and close this issue.

    Thank you.
    Alexis

    #10

    Version:6.x-3.1» 6.x-3.5

    Well, I finally got a chance to review these changes and the 6.x-3.5 version does indeed filter out the HTML control characters. Basically, it is now functional, but leaves a very ugly id / anchor: All of the tokens, including 'a', 'href', and "the referred url" are left in the id, so the resulting URL+anchor is huge. We would prefer to see the anchor generated from the title information that is actually displayed to user's.

    Also, we are having problems with the following characters in anchors:
    - numeric characters
    - periods characters
    - underscore characters at the beginning of anchors

    So, I re-rolled our patch for 3.5.

    AttachmentSize
    tableofcontents6.x-3.5-mod.diff 1.5 KB

    #11

    Status:needs review» fixed

    Hi Stacy,

    As mentioned in my earlier post, we probably want to keep some of the tags. Maybe not you, but some other people probably would want to. So I added an option to let you define which tags are kept (the list can be empty) and also which characters to remove from the identifiers. In regard to the identifiers, there was actually a bug since an identifier cannot start but with a letter ([A-Za-z]). So I fixed that part too! (it was partially done in your fix.)

    This is in the CVS, and will appear as the -dev within 12h. It will be part of 3.6.

    Thank you.
    Alexis

    P.S. Feel free to reopen the bug if you still have problems after you defined the settings in your formats.

    #12

    Status:fixed» closed (fixed)

    Automatically closed -- issue fixed for 2 weeks with no activity.