Uploaded image for project: 'Moodle'
  1. Moodle
  2. MDL-32317

wiki html parser does not recognize h1 section headers if they contain extra tags inside of them

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Won't Fix
    • Icon: Minor Minor
    • None
    • 2.2.2
    • Wiki (2.x)
    • MOODLE_22_STABLE

      If you create a wiki using the html format (others not tested) then create a new section header using h1 tags. If you also include an additional tag inside of that html tag - such as a span tag - clicking the corresponding "[edit]" link will give an 'invalid section' error. I believe this has to do with the additional html tags being removed before being handed off to the html parser. The simple fix seems to be to expand the regex in the html parser to allow it to match on tags inside of the h1 tags as well.

      Example code to cause the problem

      <h1><span style="color:red">My awesome wiki page</span></h1>

      A not so elegant switch of the regex on line 54 of mod/wiki/parser/markups/html.php from

      preg_match("/(.*?)({$h1[0]}\s*\Q$header\E\s*{$h1[1]}.*?)((?:\n{$h1[0]}.*)|$)/is", $text, $match);

      to

      preg_match("/(.*?)({$h1[0]}[\S\s]*\Q$header\E[\S\s]*{$h1[1]}.*?)((?:\n{$h1[0]}.*)|$)/is", $text, $match);

      fixes the issue, but might also cause additional false matches.

            Unassigned Unassigned
            mulroony Patrick Mulrooney (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved:

                Error rendering 'clockify-timesheets-time-tracking-reports:timer-sidebar'. Please contact your Jira administrators.