Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(320)

Side by Side Diff: tools/jsmin.py

Issue 1209713003: jsmin.py: Fix issue with escaping of back ticks (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 #!/usr/bin/python2.4 1 #!/usr/bin/python2.4
2 2
3 # Copyright 2012 the V8 project authors. All rights reserved. 3 # Copyright 2012 the V8 project authors. All rights reserved.
4 # Redistribution and use in source and binary forms, with or without 4 # Redistribution and use in source and binary forms, with or without
5 # modification, are permitted provided that the following conditions are 5 # modification, are permitted provided that the following conditions are
6 # met: 6 # met:
7 # 7 #
8 # * Redistributions of source code must retain the above copyright 8 # * Redistributions of source code must retain the above copyright
9 # notice, this list of conditions and the following disclaimer. 9 # notice, this list of conditions and the following disclaimer.
10 # * Redistributions in binary form must reproduce the above 10 # * Redistributions in binary form must reproduce the above
(...skipping 223 matching lines...) Expand 10 before | Expand all | Expand 10 after
234 # Strip leading and trailing spaces. 234 # Strip leading and trailing spaces.
235 line = re.sub(r"^ +", "", line) 235 line = re.sub(r"^ +", "", line)
236 line = re.sub(r" +$", "", line) 236 line = re.sub(r" +$", "", line)
237 # A regexp that matches a literal string surrounded by "double quotes". 237 # A regexp that matches a literal string surrounded by "double quotes".
238 # This regexp can handle embedded backslash-escaped characters including 238 # This regexp can handle embedded backslash-escaped characters including
239 # embedded backslash-escaped double quotes. 239 # embedded backslash-escaped double quotes.
240 double_quoted_string = r'"(?:[^"\\]|\\.)*"' 240 double_quoted_string = r'"(?:[^"\\]|\\.)*"'
241 # A regexp that matches a literal string surrounded by 'single quotes'. 241 # A regexp that matches a literal string surrounded by 'single quotes'.
242 single_quoted_string = r"'(?:[^'\\]|\\.)*'" 242 single_quoted_string = r"'(?:[^'\\]|\\.)*'"
243 # A regexp that matches a template string 243 # A regexp that matches a template string
244 template_string = r"`(?:[^'\\]|\\.)*`" 244 template_string = r"`(?:[^`\\]|\\.)*`"
245 # A regexp that matches a regexp literal surrounded by /slashes/. 245 # A regexp that matches a regexp literal surrounded by /slashes/.
246 # Don't allow a regexp to have a ) before the first ( since that's a 246 # Don't allow a regexp to have a ) before the first ( since that's a
247 # syntax error and it's probably just two unrelated slashes. 247 # syntax error and it's probably just two unrelated slashes.
248 # Also don't allow it to come after anything that can only be the 248 # Also don't allow it to come after anything that can only be the
249 # end of a primary expression. 249 # end of a primary expression.
250 slash_quoted_regexp = r"(?<![\w$'\")\]])/(?:(?=\()|(?:[^()/\\]|\\.)+)(?:\( [^/\\]|\\.)*/" 250 slash_quoted_regexp = r"(?<![\w$'\")\]])/(?:(?=\()|(?:[^()/\\]|\\.)+)(?:\( [^/\\]|\\.)*/"
251 # Replace multiple spaces with a single space. 251 # Replace multiple spaces with a single space.
252 line = re.sub("|".join([double_quoted_string, 252 line = re.sub("|".join([double_quoted_string,
253 single_quoted_string, 253 single_quoted_string,
254 template_string, 254 template_string,
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
289 r"\{", # Curly braces. 289 r"\{", # Curly braces.
290 r"\}", 290 r"\}",
291 r"\bvar [\w$%,]+", # var declarations. 291 r"\bvar [\w$%,]+", # var declarations.
292 function_declaration_regexp, 292 function_declaration_regexp,
293 variable_use_regexp]), 293 variable_use_regexp]),
294 self.Declaration, 294 self.Declaration,
295 line) 295 line)
296 new_lines.append(line) 296 new_lines.append(line)
297 297
298 return "\n".join(new_lines) + "\n" 298 return "\n".join(new_lines) + "\n"
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698