Skip to content

Commit 732ae57

Browse files
committed
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#8760
1 parent a8cbc28 commit 732ae57

File tree

2 files changed

+5288
-56
lines changed

2 files changed

+5288
-56
lines changed

python/servo/bootstrap_commands.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -251,7 +251,7 @@ def bootstrap_hsts_preload(self, force=False):
251251

252252
# The chromium "json" has single line comments in it which, of course,
253253
# are non-standard/non-valid json. Simply strip them out before parsing
254-
content_json = re.sub(r'//.*$', '', content_decoded, flags=re.MULTILINE)
254+
content_json = re.sub(r'(^|\s+)//.*$', '', content_decoded, flags=re.MULTILINE)
255255

256256
try:
257257
pins_and_static_preloads = json.loads(content_json)

0 commit comments

Comments
 (0)