Moodle
  1. Moodle
  2. MDL-29585

Special characters in wiki section throw error

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Minor Minor
    • Resolution: Fixed
    • Affects Version/s: 2.0.4, 2.1.1, 2.5.4, 2.6.1
    • Fix Version/s: 2.7.4, 2.8.2
    • Component/s: Wiki (2.x)
    • Labels:
    • Testing Instructions:
      Hide
      Test 1
      1. Create a wiki
      2. Add a page of each type (html, creole, nwiki)
        • Each page must contain minimum 3 headings
        • There should be heading containing a URL, one containing an ampersand (&), one containing whatever you like.

          Example for Creole:
          = Code & Test =
          Using HTML entities...
           
          = Another áéíóúç€ test =
          Using non-ascii characters
           
          = Another http://moodle.org test =
          Using a URL http://moodle.org test
          

      3. Visit each page and make sure...
        • ... you can use on the [Edit] link (both in TOC and next to the header)
        • ... the edit page shows the content of the right section
        • ... the URL in the header in the TOC is not a link
        • ... the URL in the header in the content is a link, but only for HTML format
      Test 2
      1. Run the unit tests in mod/wiki/tests/wikiparser_test.php
      Show
      Test 1 Create a wiki Add a page of each type (html, creole, nwiki) Each page must contain minimum 3 headings There should be heading containing a URL, one containing an ampersand (&), one containing whatever you like. Example for Creole: = Code & Test = Using HTML entities...   = Another áéíóúç€ test = Using non-ascii characters   = Another http://moodle.org test = Using a URL http://moodle.org test Visit each page and make sure ... ... you can use on the [Edit] link (both in TOC and next to the header) ... the edit page shows the content of the right section ... the URL in the header in the TOC is not a link ... the URL in the header in the content is a link, but only for HTML format Test 2 Run the unit tests in mod/wiki/tests/wikiparser_test.php
    • Affected Branches:
      MOODLE_20_STABLE, MOODLE_21_STABLE, MOODLE_25_STABLE, MOODLE_26_STABLE
    • Fixed Branches:
      MOODLE_27_STABLE, MOODLE_28_STABLE
    • Pull from Repository:
    • Pull 2.7 Branch:
    • Pull 2.8 Branch:
    • Pull Master Branch:
      MDL-29585-master
    • Sprint:
      BACKEND Sprint 18

      Description

      Adding html special characters like "& < >" in wiki section throw error.
      Steps to reproduce.
      1. Create a wiki - Creole format
      2. Add header "= Level 1 & 2 Header =" and Save
      3. Click on edit hyperlink(Section edit link, next to "Level 1 & 2 Header")
      4. It will throw error

        Gliffy Diagrams

          Issue Links

            Activity

            Hide
            Rajesh Taneja added a comment -

            was encountered while reviewing MDL-28725

            Show
            Rajesh Taneja added a comment - was encountered while reviewing MDL-28725
            Hide
            Eloy Lafuente (stronk7) added a comment - - edited

            Another example leading to problems (html wiki):

            <h1>Code &amp; Test</h1>
            <p>adad</p>
            <p>adad</p>
            <p> </p>
            <p>Does this work?</p>
            <h1>Another áéíóú test</h1>
            <p>adad</p>
            <p>adad</p>
            <p> </p>
            <p>Does this work?</p>
            <h1>Another http://apple.com test</h1>
            <p>adad</p>
            <p>adad</p>
            <p> </p>
            <p>Does this work?</p>
            

            under master, 21 and 20. The 1st (containing ampersands) and the 2nd sections are working ok.

            The 3rd is failing badly (table of contents borked and edit section leading to error)

            Ciao

            Show
            Eloy Lafuente (stronk7) added a comment - - edited Another example leading to problems (html wiki): <h1>Code &amp; Test</h1> <p>adad</p> <p>adad</p> <p> </p> <p>Does this work?</p> <h1>Another áéíóú test</h1> <p>adad</p> <p>adad</p> <p> </p> <p>Does this work?</p> <h1>Another http://apple.com test</h1> <p>adad</p> <p>adad</p> <p> </p> <p>Does this work?</p> under master, 21 and 20. The 1st (containing ampersands) and the 2nd sections are working ok. The 3rd is failing badly (table of contents borked and edit section leading to error) Ciao
            Hide
            Michael de Raadt added a comment -

            Thanks for reporting this issue.

            We have detected that this issue has been inactive for over a year. It was reported as affecting versions that are no longer supported.

            If you believe that this issue is still relevant to current versions (2.5 and beyond), please comment on the issue. Issues left inactive for a further month will be closed.

            Michael d.

            TW9vZGxlDQo=

            Show
            Michael de Raadt added a comment - Thanks for reporting this issue. We have detected that this issue has been inactive for over a year. It was reported as affecting versions that are no longer supported. If you believe that this issue is still relevant to current versions (2.5 and beyond), please comment on the issue. Issues left inactive for a further month will be closed. Michael d. TW9vZGxlDQo=
            Hide
            Michael de Raadt added a comment -

            I'm closing this issue as it has been inactive for over a year has been recorded as affecting versions that are no longer supported.

            This is being done as part of a bulk annual clean-up of issues.

            If you still believe this is an issue in supported versions, please create a new issue.

            Show
            Michael de Raadt added a comment - I'm closing this issue as it has been inactive for over a year has been recorded as affecting versions that are no longer supported. This is being done as part of a bulk annual clean-up of issues. If you still believe this is an issue in supported versions, please create a new issue.
            Hide
            Marina Glancy added a comment -

            reopening as this is still an issue

            Show
            Marina Glancy added a comment - reopening as this is still an issue
            Hide
            Frédéric Massart added a comment -

            Here is a patch that fixes the problem. I also added some Unit Tests that confirm what should happen, though they are not very easy to read...

            Cheers,
            Fred

            Show
            Frédéric Massart added a comment - Here is a patch that fixes the problem. I also added some Unit Tests that confirm what should happen, though they are not very easy to read... Cheers, Fred
            Hide
            CiBoT added a comment -

            Fails against automated checks.

            Checked MDL-29585 using repository: git://github.com/FMCorz/moodle.git

            More information about this report

            Show
            CiBoT added a comment - Fails against automated checks. Checked MDL-29585 using repository: git://github.com/FMCorz/moodle.git MOODLE_27_STABLE (branch: MDL-29585-27 | CI Job ) Coding style problems found master (branch: MDL-29585-master | CI Job ) Coding style problems found More information about this report
            Hide
            Mark Nelson added a comment -

            Hey Fred, looks good! Very minor points which you can ignore as they are not critical. The file mod/wiki/parser/markups/html.php has an unnecessary new line after the constructor and the unit tests add an unnecessary new line after the function name and before the end of the file. Feel free to ignore and push for integration.

            Show
            Mark Nelson added a comment - Hey Fred, looks good! Very minor points which you can ignore as they are not critical. The file mod/wiki/parser/markups/html.php has an unnecessary new line after the constructor and the unit tests add an unnecessary new line after the function name and before the end of the file. Feel free to ignore and push for integration.
            Hide
            Mark Nelson added a comment -

            Also, I don't think there is any reason to edit the function generate_header() in mod/wiki/parser/markups/wikimarkup.php, but there is no harm in it either.

            Show
            Mark Nelson added a comment - Also, I don't think there is any reason to edit the function generate_header() in mod/wiki/parser/markups/wikimarkup.php, but there is no harm in it either.
            Hide
            Frédéric Massart added a comment -

            Thanks Mark.

            I have removed the new line from the code, not the Unit Tests. Also you were right, I had initially changed generate_header(), then not, but left the lines split. I have reverted that as well.

            Pushing for integration.

            Cheers,
            Fred

            Show
            Frédéric Massart added a comment - Thanks Mark. I have removed the new line from the code, not the Unit Tests. Also you were right, I had initially changed generate_header(), then not, but left the lines split. I have reverted that as well. Pushing for integration. Cheers, Fred
            Hide
            CiBoT added a comment -

            Moving this issue to current integration cycle, will be reviewed soon. Thanks for the hard work!

            Show
            CiBoT added a comment - Moving this issue to current integration cycle, will be reviewed soon. Thanks for the hard work!
            Hide
            Sam Hemelryk added a comment -

            Thanks Fred - this has been integrated now.

            Show
            Sam Hemelryk added a comment - Thanks Fred - this has been integrated now.
            Hide
            John Okely added a comment -

            On an HTML wiki page if the automatic url is at the end of the title, then the edit link will break

            <p><span style="color:inherit;font-family:inherit;font-size:32px;font-weight:bold;line-height:40px;">Header http://moodle.org test</span><br></p>
            <p>Paragraph</p>
            <h1>Header http://moodle.org</h1>
            <p>Paragraph<br></p>

            Show
            John Okely added a comment - On an HTML wiki page if the automatic url is at the end of the title, then the edit link will break <p><span style="color:inherit;font-family:inherit;font-size:32px;font-weight:bold;line-height:40px;">Header http://moodle.org test</span><br></p> <p>Paragraph</p> <h1>Header http://moodle.org</h1> <p>Paragraph<br></p>
            Hide
            Frédéric Massart added a comment -

            Thanks for spotting that John, this really is an edge case.

            Here is a fix: https://github.com/FMCorz/moodle/compare/MDL-29585-master-fixup%5E...MDL-29585-master-fixup

            git pull https://github.com/FMCorz/moodle.git MDL-29585-master-fixup
            

            Cheers,
            Fred

            Show
            Frédéric Massart added a comment - Thanks for spotting that John, this really is an edge case. Here is a fix: https://github.com/FMCorz/moodle/compare/MDL-29585-master-fixup%5E...MDL-29585-master-fixup git pull https://github.com/FMCorz/moodle.git MDL-29585-master-fixup Cheers, Fred
            Hide
            Dan Poltawski added a comment -

            Thanks fred, pulled and cherry-picked to 28/27

            Show
            Dan Poltawski added a comment - Thanks fred, pulled and cherry-picked to 28/27
            Hide
            Dan Poltawski added a comment -

            Unfortunately this is breaking unit tests on 2.7:

            mod_wiki_wikiparser_test::test_special_headings
            Failed asserting that two strings are equal.
            --- Expected
            +++ Actual
            @@ @@
            -'<h1><a name="toc-1"></a>Code &amp; Test<a href="edit.php?pageid=&amp;section=Code+%26amp%3B+Test" class="wiki_edit_section">[edit]</a></h1>
            +'<h1><a name="toc-1"></a>Code &amp; Test <a href="edit.php?pageid=&amp;section=Code+%26amp%3B+Test" class="wiki_edit_section">[edit]</a></h1>
             '
             
            /Users/Shared/Jenkins/Home/git_repositories/MOODLE_27_STABLE/mod/wiki/tests/wikiparser_test.php:99
            /Users/Shared/Jenkins/Home/git_repositories/MOODLE_27_STABLE/lib/phpunit/classes/basic_testcase.php:64
            

            Show
            Dan Poltawski added a comment - Unfortunately this is breaking unit tests on 2.7: mod_wiki_wikiparser_test::test_special_headings Failed asserting that two strings are equal. --- Expected +++ Actual @@ @@ -'<h1><a name="toc-1"></a>Code &amp; Test<a href="edit.php?pageid=&amp;section=Code+%26amp%3B+Test" class="wiki_edit_section">[edit]</a></h1> +'<h1><a name="toc-1"></a>Code &amp; Test <a href="edit.php?pageid=&amp;section=Code+%26amp%3B+Test" class="wiki_edit_section">[edit]</a></h1> '   /Users/Shared/Jenkins/Home/git_repositories/MOODLE_27_STABLE/mod/wiki/tests/wikiparser_test.php:99 /Users/Shared/Jenkins/Home/git_repositories/MOODLE_27_STABLE/lib/phpunit/classes/basic_testcase.php:64
            Hide
            Dan Poltawski added a comment -

            I pushed a patch fixing these fails

            Show
            Dan Poltawski added a comment - I pushed a patch fixing these fails
            Hide
            John Okely added a comment - - edited

            Thanks Fred, thanks Dan, looking good. Testing passed on master, 28 and 27.

            Prexisting bugs I found:

            • In an HTML page, if you have a manually created link in the header, clicking on the edit link will result in a "invalidsection" error. Issue: MDL-44962
            • In an Nwiki page, if you have a paragraph directly before a header, the edit link will be directly at the end of the header, instead of being aligned to the right MDL-48307
            Show
            John Okely added a comment - - edited Thanks Fred, thanks Dan, looking good. Testing passed on master, 28 and 27. Prexisting bugs I found: In an HTML page, if you have a manually created link in the header, clicking on the edit link will result in a "invalidsection" error. Issue: MDL-44962 In an Nwiki page, if you have a paragraph directly before a header, the edit link will be directly at the end of the header, instead of being aligned to the right MDL-48307
            Hide
            Frédéric Massart added a comment -

            Dan, I realised last night that this would have broken the Unit Tests. Thanks for fixing them.

            Thanks John!

            Show
            Frédéric Massart added a comment - Dan, I realised last night that this would have broken the Unit Tests. Thanks for fixing them. Thanks John!
            Hide
            Dan Poltawski added a comment -

            Thanks for your contributions! This change is now available from the main moodle.git repository and will shortly be available on download.moodle.org.

            Optimism is an occupational hazard of programming; feedback is the treatment.
            – Kent Beck

            Show
            Dan Poltawski added a comment - Thanks for your contributions! This change is now available from the main moodle.git repository and will shortly be available on download.moodle.org. Optimism is an occupational hazard of programming; feedback is the treatment. – Kent Beck

              People

              • Votes:
                0 Vote for this issue
                Watchers:
                7 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:

                  Agile