Uploaded image for project: 'Maven Doxia'
  1. Maven Doxia
  2. DOXIA-441

HTML tags produce undefined behavior on the TWiki parser

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 1.1.4
    • 1.4
    • Module - Twiki
    • None
    • RHEL 5.5, java 1.6.0_20
    • Patch

    Description

      I'm using the TWiki parser in conjunction with a sink to format some twiki text. When putting some html tags in the code, the parser produces invalid output. I found this bug while working with a home-brewed sink, but later I tried with other sinks and it was also the case, which pointed out that the fault is actually in the parser. Actually the test case I'm attaching is using a XhtmlBaseSink sink.

      The fault seems to be in org.apache.maven.doxia.module.twiki.parser.TextParser. I see one of two possibilities (but I don't have the time to produce a patch, and I prefer just to explain my findings):

      • Fix the HTML_TAG_PATTERN pattern, since it is detecting, in the example, the whole " and a bit of <font color=\"red\">red</font>" string, instead of just "<font color=\"red\">red</font>"
      • If that's not possible, then the pattern compiled in line 117/118 should be changed to take into account the content before the HTML tag, so it would be "(.)?(
        <" + tag + ".\\>)(.)?(\\<
        /" + tag + "
        >)(.*)?" (the difference is the initial "(.
        )?"). The logic with the group numbers should be changed too
      • Other solution is to take into account the restul of xhtmlMatcher.start(1) in TextParser#parseXHTML:331, so it realizes that there is normal text before the actual tag.

      Please point out if this is really a bug in the TWiki parser, or if I'm simply doing something wrong. I couldn't find any reference in the mailing lists or whatsoever, and I'm inclined to see this as a bug; therefore, I'm opening this ticket.

      Cheers

      Attachments

        1. TWikiParserTest.java
          2 kB
          Rodrigo Tobar

        Issue Links

          Activity

            People

              rfscholte Robert Scholte
              rtobar Rodrigo Tobar
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: