Improved code to handle LR throughout

This commit is contained in:
Matt Pass
2017-02-21 18:34:07 +00:00
parent 0f971b547e
commit 4bf04b1c08

View File

@@ -112,11 +112,11 @@ if ($_GET['action']=="load") {
if($encoding=="") {
$encoding="UTF-8";
}
// Left trim any \r from start of text after setting HTML entities on it according to encoding
$loadedFile = ltrim(htmlentities($loadedFile,ENT_COMPAT,$encoding),"\r");
if (substr($loadedFile,0,1) == "\n") {
$loadedFile = "
".substr($loadedFile,1);
}
// Get content and set HTML entities on it according to encoding
$loadedFile = htmlentities($loadedFile,ENT_COMPAT,$encoding);
// Remove \r chars and replace \n with carriage return HTML entity char
$loadedFile = preg_replace('/\\r/','',$loadedFile);
$loadedFile = preg_replace('/\\n/','
',$loadedFile);
echo '</script><textarea name="loadedFile" id="loadedFile">'.$loadedFile.'</textarea><script>';
// Run our custom processes
include_once("../processes/on-file-load.php");