Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

The regexp in _filterargs fails when packed code has embedded new lines #75

Closed
d1g1t4l opened this Issue · 1 comment

2 participants

@d1g1t4l

Just what it says in the title. I fixed it by removing the new line characters before applying the regex. Here is the patch:

diff --git a/python/jsbeautifier/unpackers/packer.py b/python/jsbeautifier/unpackers/packer.py
index 1029f56..05515bc 100644
--- a/python/jsbeautifier/unpackers/packer.py
+++ b/python/jsbeautifier/unpackers/packer.py
@@ -43,7 +43,7 @@ def _filterargs(source):
     """Juice from a source file the four args needed by decoder."""
     argsregex = (r"}\('(.*)', *(\d+), *(\d+), *'(.*)'\."
                  r"split\('\|'\), *(\d+), *(.*)\)\)")
-    args = re.search(argsregex, source).groups()
+    args = re.search(argsregex, source.replace("\n", "")).groups()
     try:
         return args[0], args[3].split('|'), int(args[1]), int(args[2])
     except ValueError:
diff --git a/tests/run-tests b/tests/run-tests
index fd3b953..1618258 100755
--- a/tests/run-tests
+++ b/tests/run-tests
@@ -1,4 +1,4 @@
-#!/usr/bin/js
+#!/usr/bin/jsscript-1.6

 // a little helper for testing from command line
 // just run it, it will output the test results
@esseks esseks was assigned
@esseks

Many thanks for reporting the error. The solution adopted will be a bit different: your patch needs a little fix to handle exotic line terminators ('\r\n', '\n\r' and '\r'). Furthermore, a \n may be embedded in a voluntarily malformed symbol string...

@esseks esseks closed this
@bitwiseman bitwiseman referenced this issue from a commit
@bitwiseman bitwiseman Verify correct handling of no-semicolon declaration followed by function
Not sure when this got fixed, but it is.
Closes #75
f417f83
@esseks esseks was unassigned by d1g1t4l
@bitwiseman bitwiseman referenced this issue from a commit
@bitwiseman bitwiseman Verify correct handling of no-semicolon declaration followed by function
Not sure when this got fixed, but it is.
Closes #75
542b76a
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.