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

Unified Diff: grit/format/html_inline.py

Issue 324383003: Teach grit that file.svg is an SVG. (Closed) Base URL: https://chromium.googlesource.com/external/grit-i18n.git@master
Patch Set: Created 6 years, 6 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: grit/format/html_inline.py
diff --git a/grit/format/html_inline.py b/grit/format/html_inline.py
index c2b898e1e0cdbf2d303b3a5bf99a47230f26a80b..8ba6ea2b8848dd9b028fae46ef9aea244c497b9c 100755
--- a/grit/format/html_inline.py
+++ b/grit/format/html_inline.py
@@ -22,8 +22,10 @@ from grit import util
# There is a python bug that makes mimetypes crash if the Windows
# registry contains non-Latin keys ( http://bugs.python.org/issue9291
# ). Initing manually and blocking external mime-type databases will
-# prevent that bug and still give us the data we need.
+# prevent that bug and if we add svg manually, it will still give us
+# the data we need.
mimetypes.init([])
+mimetypes.add_type('image/svg+xml', '.svg')
DIST_DEFAULT = 'chromium'
DIST_ENV_VAR = 'CHROMIUM_BUILD'
@@ -115,7 +117,12 @@ def SrcInlineAsDataURL(
if names_only:
return ""
- mimetype = FixupMimeType(mimetypes.guess_type(filename)[0]) or 'text/plain'
+ platform_mimetype_guess = mimetypes.guess_type(filename)[0]
+ if platform_mimetype_guess is None:
+ raise Exception('%s is of an an unknown type and '
+ 'cannot be stored in a data url.' % filename)
+ else:
+ mimetype = FixupMimeType(platform_mimetype_guess)
newt (away) 2014/06/11 18:31:25 looks like FixusMimeType() isn't needed anymore, s
inline_data = base64.standard_b64encode(util.ReadFile(filepath, util.BINARY))
prefix = src_match.string[src_match.start():src_match.start('filename')]
« 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