Commit b74f2614 authored by Hamish Friedlander's avatar Hamish Friedlander

Make UTF-8 safe

parent ba1c916b
......@@ -225,15 +225,19 @@ class DocumentImportInnerField extends UploadField {
return $content;
}
// you need Tidy, i.e. port install php5-tidy
// Clean up with tidy (requires tidy module)
$tidy = new Tidy();
$tidy->parseString($content, array('output-xhtml' => true), 'utf8');
$tidy->cleanRepair();
// Add a header that makes DOMDocument UTF-8 safe
$html = str_replace('<head>', '<head><meta http-equiv="content-type" content="text/html; charset=utf-8">', $tidy);
// Load in the HTML
$doc = new DOMDocument();
$doc->strictErrorChecking = false;
libxml_use_internal_errors(true);
$doc->loadHTML('' . $tidy);
$doc->loadHTML($html);
$xpath = new DOMXPath($doc);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment