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

Portfolio rewrite pluginfile URLs does not work with HTML5 tags

    XMLWordPrintable

Details

    Description

      When exporting a forum post containing an image tag (created with Atto), these warning are raised.

      ( ! ) Warning: DOMDocument::loadXML(): Opening and ending tag mismatch: br line 1 and p in Entity, line: 1 in /home/fred/www/repositories/im/moodle/lib/portfoliolib.php on line 1232
      Call Stack
      #	Time	Memory	Function	Location
      1	0.0005	317712	{main}( )	../add.php:0
      2	0.1859	32198224	portfolio_exporter->process_stage( )	../add.php:265
      3	0.2100	32201168	portfolio_exporter->process_stage( )	../exporter.php:233
      4	0.2187	32203008	portfolio_exporter->process_stage_package( )	../exporter.php:227
      5	0.2187	32203904	forum_portfolio_caller->prepare_package( )	../exporter.php:459
      6	0.2187	32204656	forum_portfolio_caller->prepare_post( )	../locallib.php:215
      7	0.2202	32297784	portfolio_rewrite_pluginfile_urls( )	../locallib.php:299
      8	0.2202	32299880	preg_replace_callback ( )	../portfoliolib.php:1370
      9	0.2202	32302096	partial->method( )	../portfoliolib.php:1370
      10	0.2202	32303672	call_user_func_array:{/home/fred/www/repositories/im/moodle/lib/moodlelib.php:9434} ( )	../moodlelib.php:9434
      11	0.2203	32303976	portfolio_rewrite_pluginfile_url_callback( )	../moodlelib.php:9434
      12	0.2203	32304232	loadXML ( )	../portfoliolib.php:1232
       
      ( ! ) Warning: DOMDocument::loadXML(): Premature end of data in tag img line 1 in Entity, line: 1 in /home/fred/www/repositories/im/moodle/lib/portfoliolib.php on line 1232
      Call Stack
      #	Time	Memory	Function	Location
      1	0.0005	317712	{main}( )	../add.php:0
      2	0.1859	32198224	portfolio_exporter->process_stage( )	../add.php:265
      3	0.2100	32201168	portfolio_exporter->process_stage( )	../exporter.php:233
      4	0.2187	32203008	portfolio_exporter->process_stage_package( )	../exporter.php:227
      5	0.2187	32203904	forum_portfolio_caller->prepare_package( )	../exporter.php:459
      6	0.2187	32204656	forum_portfolio_caller->prepare_post( )	../locallib.php:215
      7	0.2202	32297784	portfolio_rewrite_pluginfile_urls( )	../locallib.php:299
      8	0.2202	32299880	preg_replace_callback ( )	../portfoliolib.php:1370
      9	0.2202	32302096	partial->method( )	../portfoliolib.php:1370
      10	0.2202	32303672	call_user_func_array:{/home/fred/www/repositories/im/moodle/lib/moodlelib.php:9434} ( )	../moodlelib.php:9434
      11	0.2203	32303976	portfolio_rewrite_pluginfile_url_callback( )	../moodlelib.php:9434
      12	0.2203	32304232	loadXML ( )	../portfoliolib.php:1232
      

      After investigation, this seems broken because portfolio_rewrite_pluginfile_urls() expects IMG tags to be closed properly, which is not the case for HTML5 content. This issue is only highlighted now that Atto outputs HTML5 IMG tags.

      Sample test:

      <?php
      define('CLI_SCRIPT', true);
      require('config.php');
      require_once($CFG->libdir . '/portfoliolib.php');
       
      $html = '<p>Post and image.</p><p><img src="@@PLUGINFILE@@/1.png" alt="" width="902" height="245" role="presentation" style="vertical-align:text-bottom; margin: 0 .5em;" class="img-responsive"><br></p>';
      portfolio_rewrite_pluginfile_urls($html, 1, 'test', 'test', 0, '', array(), $html);
      

      Attachments

        Issue Links

          Activity

            People

              fred Frédéric Massart
              fred Frédéric Massart
              Damyon Wiese Damyon Wiese
              Dan Poltawski Dan Poltawski
              Rajesh Taneja Rajesh Taneja
              Andrew Lyons, Huong Nguyen, Jun Pataleta, Michael Hawkins, Shamim Rezaie, Simey Lameze, Stevani Andolo, Amaia Anabitarte, Carlos Escobedo, Ferran Recio, Ilya Tregubov, Laurent David, Raquel Ortega, Sara Arjona (@sarjona)
              Votes:
              0 Vote for this issue
              Watchers:
              6 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:
                12/May/14