Skip to content
Snippets Groups Projects
Commit 6db7468b authored by Andreas Gohr's avatar Andreas Gohr
Browse files

make sure loaded text has the right encoding

When pages contain non-UTF8 chars (eg. when posted through a script or
when edited on the filesystem, parts of DokuWiki can break resulting in
missing page content. This fixes these problems by forcing the content
to UTF-8 on load. This will result in bad characters for input that is
not latin1 but contents will at least be visible.
parent 46ac8ef9
No related branches found
No related tags found
No related merge requests found
......@@ -781,11 +781,19 @@ function unlock($id) {
/**
* convert line ending to unix format
*
* also makes sure the given text is valid UTF-8
*
* @see formText() for 2crlf conversion
* @author Andreas Gohr <andi@splitbrain.org>
*/
function cleanText($text) {
$text = preg_replace("/(\015\012)|(\015)/", "\012", $text);
// if the text is not valid UTF-8 we simply assume latin1
// this won't break any worse than it breaks with the wrong encoding
// but might actually fix the problem in many cases
if(!utf8_check($text)) $text = utf8_encode($text);
return $text;
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment