Anthony Van de Gejuchte
bb9c9707aa
Don't allow with statements in strict mode
2016-06-12 19:08:16 +02:00
Anthony Van de Gejuchte
4d7746baf3
Throw errors in strict mode for octal strings
...
Adds a directive tracker for the parser/tokenizer to
allow parsing depending on directive context.
2016-06-12 14:27:08 +02:00
Anthony Van de Gejuchte
00ad57e393
Do not allow newlines in regex
2016-06-05 17:02:19 +02:00
kzc
f39fd3d583
Handle CR line endings in comments.
...
Fixes #1050
2016-05-04 20:02:29 +02:00
kzc
e4fa4b109a
Parse comments without recursion to avoid RangeError.
...
Fixes #993
2016-04-16 02:02:47 -04:00
kzc
a9d4a6291b
Do not produce let as a variable name in mangle.
...
Would previously occur in large generated functions with 21,000+ variables.
Fixes #986 .
2016-03-15 11:20:32 -04:00
Anthony Van de Gejuchte
26641f3fb2
Allow operator names as getters/setters
...
Fixes #919
Fix provided by @kzc
2016-01-19 19:28:51 +01:00
Anthony Van de Gejuchte
6f3e35bb3f
Fix ch that could contain other newline characters
2015-12-27 22:24:37 +01:00
Anthony Van de Gejuchte
174404c0f3
Do not allow newlines in string literals
2015-12-26 15:08:37 +01:00
Anthony Van de Gejuchte
bd99b00413
Semicolon after do...while statement is optional
2015-12-17 23:02:35 +01:00
Mihai Bazon
08623aa6a7
Fix output for "use asm" code from SpiderMonkey AST
...
(will only work properly if the SM tree contains "raw" properties for
Literal number nodes)
2015-11-12 12:18:25 +02:00
Mihai Bazon
7691bebea5
Rework has_directive
...
It's now available during tree walking, i.e. walker.has_directive("use
asm"), rather than as part of the scope. It's thus no longer necessary
to call `figure_out_scope` before codegen. Added special bits in the
code generator to overcome the fact that it doesn't inherit from
TreeWalker.
Fix #861
2015-11-11 22:15:25 +02:00
Mihai Bazon
18d37ac761
Fix parsing invalid input
...
i.e. `x = 1.xe` — because parseFloat("1.xe") returns 1, this parsed as
`x = 1`.
Ref #857
2015-11-09 13:15:20 +02:00
Richard van Velzen
63d35f8f6d
Prevent ReDoS by not using a regexp to verify floating point numbers
...
`parseFloat` will return `NaN` for invalid numbers anyway, which is the check used to throw the parse error.
Fixes #857
2015-11-09 11:28:27 +01:00
kzc
4d2f7d83af
Fix handling of "use asm" when no command line flags are passed to uglifyjs. SCOPE_IS_NEEDED is unconditionally true now. Refactored floating point literal parsing to be more in keeping with the AST class design.
2015-10-07 13:10:53 -04:00
kzc
593677d2ff
Add proper support for "use asm"; blocks. Disable -c optimization within "use asm"; sections and preserve floating point literals in their original form. Non-asm.js sections are optimized as before. Asm.js sections can still be mangled and minified of whitespace. No special command line flags are required.
2015-10-07 10:00:28 +02:00
Anthony Van de Gejuchte
c69294c449
Implement shebang support
2015-10-06 22:35:45 +02:00
Richard van Velzen
fcde6109b0
Fix bad parsing of new new x()() constructs
...
Fixes #739
2015-08-27 12:29:36 +03:00
Chris Cowan
9854deb626
Re-use the caught exception's error message in the parse error call.
2015-07-29 15:06:52 +02:00
Chris Cowan
d6814050dd
Give a good error message if an invalid regular expression is found.
2015-07-29 15:05:59 +02:00
Mihai Bazon
bce4307e9e
Treat \uFEFF as whitespace.
...
Fix #714
2015-05-20 16:17:46 +03:00
Mihai Bazon
e637bdaf4e
Only drop the BOM when it's the first character.
...
Close #704
2015-05-05 10:11:38 +03:00
Mihai Bazon
92e4340732
Fix parsing strings with literal DOS newlines
...
(should not set newline_before)
Fix #693
2015-04-23 12:08:19 +03:00
Mihai Bazon
d36faffeca
Fix parsing for U+2028 / U+2029
...
(they should be treated as whitespace)
2015-03-18 10:09:30 +02:00
Edward Casbon
ae07714927
Add filename to the JS_Parse_Error exception.
...
It would be nice to have access to the filename of the file that includes the code that causes a JavaScript error. This is especially handy if uglifying multiple files at once.
Only a small change is needed for this to happen as it's already available in the function that throws the error.
2015-02-11 23:21:22 +01:00
Mihai Bazon
fbbaa42ee5
Add option to preserve/enforce string quote style
...
`-q 0` (default) use single or double quotes such as to minimize the number of
bytes (prefers double quotes when both will do); this is the previous
behavior.
`-q 1` -- always use single quotes
`-q 2` -- always use double quotes
`-q 3` or just `-q` -- always use the original quotes.
Related codegen option: `quote_style`.
Close #495
Close #460
Some `yargs` guru please tell me why `uglifyjs --help` doesn't display the
help string for `-q` / `--quotes`, and why it doesn't output the expected
argument types anymore, like good old `optimist` did.
2015-01-27 22:26:27 +02:00
Anthony Van de Gejuchte
74cda80d3b
Add unicode digit parsing support
2015-01-20 00:17:24 +01:00
Anthony Van de Gejuchte
9a3a848cc8
Update unicode letter
2015-01-20 00:17:03 +01:00
Ingvar Stepanyan
ae5366a31d
Track ending lines/columns; fix end locations in Mozilla AST.
2015-01-06 11:32:41 +01:00
Mihai Bazon
13219cebcb
Fix handling \r\n
...
Close #437
2015-01-05 12:14:42 +02:00
Mihai Bazon
f36a1eaa8b
Add option to allow return outside of functions.
...
Close #288
2014-10-20 18:12:13 +03:00
Mihai Bazon
8fbe200012
Always quote property names that contain non-ASCII characters.
...
Fix #328
2014-04-18 10:48:44 +03:00
Mihai Bazon
1d0127de21
Fix end token for conditionals. Close #404
2014-01-21 10:38:59 +02:00
Mihai Bazon
aa9de76370
Mark yield as reserved word. Close #375 .
2013-12-22 20:52:19 +02:00
Mihai Bazon
c5ed2292bf
Fix parsing setters/getters (allow keywords for name).
...
The "key" property was always "set" or "get", which didn't make much sense.
Now it'll be the actual name of the setter/getter (AST_Node), and the
AST_Accessor object itself, which represents the function, won't store any
name.
Close #319
2013-10-30 11:50:22 +02:00
Mihai Bazon
bea3d90771
minor
2013-10-30 09:10:56 +02:00
David Glasser
bb0a762d12
Only allow identifier start characters at the beginning of identifiers.
...
Without this fix, the following source:
x = {"\u200c": 42};
would incorrectly be converted into a quoteless key. But while \u200c is allowed
to be in identifiers, it cannot be at the beginning, as per ES5.
(For example, the SockJS client library doesn't work under uglify starting with
d9ad3c7c.)
2013-10-03 17:02:19 -07:00
Mihai Bazon
7c10b25346
Support HTML5 comment syntax (enabled by default!)
...
See http://javascript.spec.whatwg.org/#comment-syntax
https://github.com/mishoo/UglifyJS/issues/503
https://github.com/marijnh/acorn/issues/62
2013-09-06 09:54:30 +03:00
Mihai Bazon
5d8da864c5
Fix names.
2013-09-02 19:38:00 +03:00
Mihai Bazon
85b527ba3d
Disallow continue referring to a non-IterationStatement. Fix #287
...
Simplifies handling of labels (their definition/references can be easily
figured out at parse time, no need to do it in `figure_out_scope`).
2013-09-02 19:36:16 +03:00
Mihai Bazon
1c6efdae34
Better fix for #286
2013-09-02 11:36:48 +03:00
Mihai Bazon
b0ca896d98
Fix parsing a.case /= 1
...
Close #286
2013-09-02 11:09:54 +03:00
Mihai Bazon
78a217b94c
Fix parsing regexp after unary-prefix operator
...
++/x/.y
Fix #284
2013-09-02 09:56:27 +03:00
Mihai Bazon
193049af19
Revert previous patch, it was no good.
2013-07-15 11:59:23 +03:00
Mihai Bazon
4a0bab0fa3
Add "position" option to parser, to specify initial pos/line/col
...
(for parsing embedded scripts)
2013-07-15 11:27:11 +03:00
Mihai Bazon
fc9ba323c4
Fix typo.
...
Close #239
2013-07-12 09:56:58 +03:00
Mihai Bazon
ca3388cf5a
Add --expr, an option to parse a single expression (suitable for JSON)
2013-05-15 13:27:23 +03:00
Mihai Bazon
d56ebd7d7b
Fix a["1_1"]
...
Close #204
2013-05-14 10:42:34 +03:00
Mihai Bazon
064e7aa1bb
Fix is_assignable
...
(not likely to be noticed, it's only used in `strict` parse mode)
2013-05-09 08:44:24 +03:00
Mihai Bazon
11e24d53a1
Fix property names
...
Close #199
2013-05-08 22:37:48 +03:00