[Pkg-javascript-commits] [uglifyjs] 25/77: Fix handling \r\n

Jonas Smedegaard dr at jones.dk
Tue May 19 00:02:29 UTC 2015


This is an automated email from the git hooks/post-receive script.

js pushed a commit to tag v2.4.18
in repository uglifyjs.

commit 13219cebcb11f95fdaa77af653e96ac42e7e6dcc
Author: Mihai Bazon <mihai at bazon.net>
Date:   Mon Jan 5 12:14:42 2015 +0200

    Fix handling \r\n
    
    Close #437
---
 lib/parse.js | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/lib/parse.js b/lib/parse.js
index 931e5f6..c3f0822 100644
--- a/lib/parse.js
+++ b/lib/parse.js
@@ -206,7 +206,7 @@ var EX_EOF = {};
 function tokenizer($TEXT, filename, html5_comments) {
 
     var S = {
-        text            : $TEXT.replace(/\r\n?|[\n\u2028\u2029]/g, "\n").replace(/\uFEFF/g, ''),
+        text            : $TEXT.replace(/\uFEFF/g, ''),
         filename        : filename,
         pos             : 0,
         tokpos          : 0,
@@ -225,10 +225,15 @@ function tokenizer($TEXT, filename, html5_comments) {
         var ch = S.text.charAt(S.pos++);
         if (signal_eof && !ch)
             throw EX_EOF;
-        if (ch == "\n") {
+        if ("\r\n\u2028\u2029".indexOf(ch) >= 0) {
             S.newline_before = S.newline_before || !in_string;
             ++S.line;
             S.col = 0;
+            if (!in_string && ch == "\r" && peek() == "\n") {
+                // treat a \r\n sequence as a single \n
+                ++S.pos;
+                ch = "\n";
+            }
         } else {
             ++S.col;
         }

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-javascript/uglifyjs.git



More information about the Pkg-javascript-commits mailing list