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

Correctly handle multiline strings in JS compressor

See
http://stackoverflow.com/questions/805107/how-to-create-multiline-strings
for info on them.
parent 55ce1101
No related branches found
No related tags found
No related merge requests found
......@@ -110,6 +110,17 @@ class js_js_compress_test extends DokuWikiTest {
$this->assertEquals(js_compress($text),$text);
}
function test_multilinestring(){
$text = 'var foo = "this is a \\
multiline string";';
$this->assertEquals('var foo="this is a multiline string";',js_compress($text));
$text = "var foo = 'this is a \\
multiline string';";
$this->assertEquals("var foo='this is a multiline string';",js_compress($text));
}
/**
* Test the files provided with the original JsStrip
*/
......
......@@ -307,7 +307,10 @@ function js_compress($s){
$j += 1;
}
}
$result .= substr($s,$i,$j+1);
$string = substr($s,$i,$j+1);
// remove multiline markers:
$string = str_replace("\\\n",'',$string);
$result .= $string;
$i = $i + $j + 1;
continue;
}
......@@ -322,7 +325,10 @@ function js_compress($s){
$j += 1;
}
}
$result .= substr($s,$i,$j+1);
$string = substr($s,$i,$j+1);
// remove multiline markers:
$string = str_replace("\\\n",'',$string);
$result .= $string;
$i = $i + $j + 1;
continue;
}
......
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