summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--_test/tests/lib/exe/js_js_compress.test.php11
-rw-r--r--lib/exe/js.php10
2 files changed, 19 insertions, 2 deletions
diff --git a/_test/tests/lib/exe/js_js_compress.test.php b/_test/tests/lib/exe/js_js_compress.test.php
index cda05162d..aa8d82933 100644
--- a/_test/tests/lib/exe/js_js_compress.test.php
+++ b/_test/tests/lib/exe/js_js_compress.test.php
@@ -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
*/
diff --git a/lib/exe/js.php b/lib/exe/js.php
index 4b72014b2..7c54f3e2e 100644
--- a/lib/exe/js.php
+++ b/lib/exe/js.php
@@ -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;
}