einars/js-beautify — Issue #75: The regexp in _filterargs fails when packed code has embedded new lines
Author: d1g1t4l
Created: 2011-10-09 10:50:04+00:00
State: open

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
```