mahara-contributors team mailing list archive
-
mahara-contributors team
-
Mailing list archive
-
Message #28122
[Bug 1482410] Re: Leap2A import problem: "simplexml_load_file()... parser error : PCDATA invalid Char value..."
Using a for-loop and the PHP chr() command, I individually tested each
ASCII character in the middle of an otherwise acceptable XML file. I
tested them plain, after passing through htmlspecialchars(), and after
passing through htmlentities(). Here is the list of the decimal integer
codes for the ASCII characters that cause SimpleXML to choke. None of
them are escaped by htmlspecialchars() or htmlentities().
$baddies =
array(0,1,2,3,4,5,6,7,8,11,12,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31);
To help with testing (because it's not always easy to generate these
characters), I've attached a file controlcharacters.txt which contains
all 29 of these characters, in between <bad> tags. Depending on your
text editor, opening it you may just see "<bad></bad>". But if you
select the whole thing and paste it into a Mahara page title, you should
be able to replicate the problem
To replicate:
1. Create a Mahara page with one or more of the forbidden characters in its page title
2. Export the page to Leap2a
3. Import the Leap2a file back into Mahara
Expected result: You've imported a copy of the page
Actual result: You get an error stack with the SimpleXML parser error as part of it.
** Attachment added: "A text file containing the range of control characters SimpleXML won't parse"
https://bugs.launchpad.net/mahara/+bug/1482410/+attachment/4440731/+files/controlcharacters.txt
--
You received this bug notification because you are a member of Mahara
Contributors, which is subscribed to Mahara.
Matching subscriptions: Subscription for all Mahara Contributors -- please ask on #mahara-dev or mahara.org forum before editing or unsubscribing it!
https://bugs.launchpad.net/bugs/1482410
Title:
Leap2A import problem: "simplexml_load_file()... parser error : PCDATA
invalid Char value..."
Status in Mahara:
In Progress
Bug description:
We had a report of a Mahara-generated Leap2a file that caused this
crash stack upon attempting to import it:
[WAR] 38 (import/leap/lib.php:126) simplexml_load_file(): /home/aaronw/dataroot/mahara/temp/import/admin-1438900425/extract/leap2a.xml:1808: parser error : PCDATA invalid Char value 11
Call stack (most recent first):
log_message("simplexml_load_file(): /home/aaronw/dataroot/mahar...", 8, true, true, "/home/aaronw/www/mahara/htdocs/import/leap/lib.php", 126) at /home/aaronw/www/mahara/htdocs/lib/errors.php:441
error(2, "simplexml_load_file(): /home/aaronw/dataroot/mahar...", "/home/aaronw/www/mahara/htdocs/import/leap/lib.php", 126, array(size 2)) at Unknown:0
simplexml_load_file("/home/aaronw/dataroot/mahara/temp/import/admin-143...", "SimpleXMLElement", 67584) at /home/aaronw/www/mahara/htdocs/import/leap/lib.php:126
PluginImportLeap->read_leap2a_xml_file() at /home/aaronw/www/mahara/htdocs/import/leap/lib.php:147
PluginImportLeap->build_default_load_mapping() at /home/aaronw/www/mahara/htdocs/import/leap/lib.php:164
PluginImportLeap->process(1) at /home/aaronw/www/mahara/htdocs/import/index.php:245
import_submit(object(Pieform), array(size 3)) at Unknown:0
call_user_func_array("import_submit", array(size 2)) at /home/aaronw/www/mahara/htdocs/lib/pieforms/pieform.php:537
Pieform->__construct(array(size 6)) at /home/aaronw/www/mahara/htdocs/lib/pieforms/pieform.php:164
Pieform::process(array(size 6)) at /home/aaronw/www/mahara/htdocs/lib/pieforms/pieform.php:71
pieform(array(size 6)) at /home/aaronw/www/mahara/htdocs/import/index.php:171
print_upload_form() at /home/aaronw/www/mahara/htdocs/import/index.php:61
Upon investigation it turned out that the leap2a XML file had a
Vertical Tab character (ASCII x0A) in one of the page titles. There is
a whole range of ASCII control characters that will cause a parser
error in SimpleXML, and if they're placed in a Mahara page title, they
will be included in the output of the Leap2a file, which will cause
Mahara to crash when it attempts to import the file.
To manage notifications about this bug go to:
https://bugs.launchpad.net/mahara/+bug/1482410/+subscriptions
References