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

Make HTMLPurifier handling of ‹nolink› tags to support them everywhere

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: 3.6.2, 3.7, 3.8
    • Fix Version/s: 3.6.6, 3.7.2
    • Component/s: Filters, General
    • Labels:

      Description

      While working on MDL-58680 tests, it was discovered that clean_text(), using the HTML Purifier... was breaking some content when <nolink> tags are used.

      So, for example, this html:

      <p>Hello, <nolink>world!</nolink></p>
      

      Is being converted to:

      <p>Hello, </p><nolink>world!</nolink>
      

      When the correct (expected) behavior, is to keep the html unmodified, because those tags should be allowed everywhere.

      Tracing back the problem it seems that @ MDL-24223, together with an HTMLPurifier upgrade, the behavior was changed:

      -        $this->addElement('nolink',  'Inline', 'Flow');
      +        $def->addElement('nolink', 'Block', 'Flow', array());
      

      Note that, surely, this has been unnoticed along all these years because we switched to the <span class="nolink> alternative for user-entered content in general long ago.

      But, irrespectively of that, the <nolink> ones should be working as expected because they can be used programmatically to skip filtering here and there (like we are trying to do @ MDL-58680) with the advantage of being removed before the final output happens.

      So, this issue is about to revert the handling of <nolink> tags back to "Inline" mode, that leads to the correct behavior of, simply, keeping HTML unmodified, without any early closing of tags (and cover the behavior with tests, to ensure it remains constant).

      Ciao

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                stronk7 Eloy Lafuente (stronk7)
                Reporter:
                stronk7 Eloy Lafuente (stronk7)
                Peer reviewer:
                Andrew Nicols
                Integrator:
                Jun Pataleta
                Tester:
                CiBoT
                Participants:
                Component watchers:
                Jake Dallimore, Jun Pataleta, Jake Dallimore, Jun Pataleta
              • Votes:
                0 Vote for this issue
                Watchers:
                2 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:
                  Fix Release Date:
                  9/Sep/19

                  Time Tracking

                  Estimated:
                  Original Estimate - Not Specified
                  Not Specified
                  Remaining:
                  Remaining Estimate - 0 minutes
                  0m
                  Logged:
                  Time Spent - 1 hour, 53 minutes
                  1h 53m