diff options
Diffstat (limited to 'chromium/tools/grit/grit/format/html_inline.py')
-rwxr-xr-x | chromium/tools/grit/grit/format/html_inline.py | 24 |
1 files changed, 12 insertions, 12 deletions
diff --git a/chromium/tools/grit/grit/format/html_inline.py b/chromium/tools/grit/grit/format/html_inline.py index 589e49b6a94..66a957aec77 100755 --- a/chromium/tools/grit/grit/format/html_inline.py +++ b/chromium/tools/grit/grit/format/html_inline.py @@ -19,6 +19,14 @@ import mimetypes from grit import lazy_re 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 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' DIST_SUBSTR = '%DISTRIBUTION%' @@ -46,17 +54,6 @@ _ICON_RE = lazy_re.compile( re.MULTILINE) - -def FixupMimeType(mime_type): - """Helper function that normalizes platform differences in the mime type - returned by the Python's mimetypes.guess_type API. - """ - mappings = { - 'image/x-png': 'image/png' - } - return mappings[mime_type] if mime_type in mappings else mime_type - - def GetDistribution(): """Helper function that gets the distribution we are building. @@ -109,7 +106,10 @@ def SrcInlineAsDataURL( if names_only: return "" - mimetype = FixupMimeType(mimetypes.guess_type(filename)[0]) or 'text/plain' + mimetype = mimetypes.guess_type(filename)[0] + if mimetype is None: + raise Exception('%s is of an an unknown type and ' + 'cannot be stored in a data url.' % filename) inline_data = base64.standard_b64encode(util.ReadFile(filepath, util.BINARY)) prefix = src_match.string[src_match.start():src_match.start('filename')] |