From 732ae5714f07fdd772a6469e1d45691bf6ae046f Mon Sep 17 00:00:00 2001 From: Sam Gibson Date: Wed, 2 Dec 2015 15:36:38 +1100 Subject: Fix the parsing of the chromium HSTS preload list Urg! The Chromium HSTS preload JSON file contains single line comments. Previously these were filtered out with a very simple regex that just looked for '//' and removed the line. Now the file has added a couple fields that have URLs in them that were erroneously removed and caused the JSON parsing to fail. This commit slightly complicates the regex to fix this specific problem. If this happens again, it's likely worth it to figure out how to use a real parser to remove the comments. servo/servo#8760 --- python/servo/bootstrap_commands.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'python/servo/bootstrap_commands.py') diff --git a/python/servo/bootstrap_commands.py b/python/servo/bootstrap_commands.py index 23d807fdb0e..b6c9143f5a8 100644 --- a/python/servo/bootstrap_commands.py +++ b/python/servo/bootstrap_commands.py @@ -251,7 +251,7 @@ class MachCommands(CommandBase): # The chromium "json" has single line comments in it which, of course, # are non-standard/non-valid json. Simply strip them out before parsing - content_json = re.sub(r'//.*$', '', content_decoded, flags=re.MULTILINE) + content_json = re.sub(r'(^|\s+)//.*$', '', content_decoded, flags=re.MULTILINE) try: pins_and_static_preloads = json.loads(content_json) -- cgit v1.2.3