New issue
Advanced search Search tips
Starred by 1 user

Issue metadata

Status: Fixed
Owner:
Closed: Dec 17
Cc:
Components:
EstimatedDays: ----
NextAction: ----
OS: ----
Pri: 3
Type: Bug



Sign in to add a comment
link

Issue 914591: Grit does not ignore polymer bindings when there are multiple url()s in "background: "

Reported by rbpotter@chromium.org, Dec 13 Project Member

Issue description

Locally added a select with multiple background images, one controlled by a polymer property, to Print Preview, i.e.: 
<select background="url([[destination.icon]]) ..., 
                    url('dropdown_arrow_image.svg') ...;">
...
</select>

This fails to inline with flattenhtml="true", see error below: 
Error processing node <?xml version="1.0" encoding="UTF-8"?>
<include allowexternalscript="true" file="${root_gen_dir}\chrome\browser\resources\print_preview\vulcanized.html" flattenhtml="true" name="IDR_PRINT_PREVIEW_VULCANIZED_HTML" type="BINDATA" use_base_dir="false" />
Traceback (most recent call last):
  File "../../tools/grit/grit.py", line 15, in <module>
    sys.exit(grit.grit_runner.Main(sys.argv[1:]))
  File "/usr/local/google/home/rbpotter/chromium/src/tools/grit/grit/grit_runner.py", line 256, in Main
    return toolobject.Run(options, args[1:])
  File "/usr/local/google/home/rbpotter/chromium/src/tools/grit/grit/tool/build.py", line 260, in Run
    self.Process()
  File "/usr/local/google/home/rbpotter/chromium/src/tools/grit/grit/tool/build.py", line 401, in Process
    self.ProcessNode(self.res, output, outfile)
  File "/usr/local/google/home/rbpotter/chromium/src/tools/grit/grit/tool/build.py", line 324, in ProcessNode
    formatted = formatter(node, output_node.GetLanguage(), output_dir=base_dir)
  File "/usr/local/google/home/rbpotter/chromium/src/tools/grit/grit/format/data_pack.py", line 83, in Format
    value = node.GetDataPackValue(lang, UTF8)
  File "/usr/local/google/home/rbpotter/chromium/src/tools/grit/grit/node/include.py", line 85, in GetDataPackValue
    data = self._GetFlattenedData(allow_external_script=allow_external_script)
  File "/usr/local/google/home/rbpotter/chromium/src/tools/grit/grit/node/include.py", line 39, in _GetFlattenedData
    allow_external_script=allow_external_script))
  File "/usr/local/google/home/rbpotter/chromium/src/tools/grit/grit/format/html_inline.py", line 536, in InlineToString
    filename_expansion_function=filename_expansion_function).inlined_data
  File "/usr/local/google/home/rbpotter/chromium/src/tools/grit/grit/format/html_inline.py", line 508, in DoInline
    flat_text = InlineCSSImages(flat_text)
  File "/usr/local/google/home/rbpotter/chromium/src/tools/grit/grit/format/html_inline.py", line 451, in InlineCSSImages
    return re.sub(css_re, lambda m: InlineCSSUrls(m, filepath), text)
  File "/usr/lib/python2.7/re.py", line 155, in sub
    return _compile(pattern, flags).sub(repl, string, count)
  File "/usr/local/google/home/rbpotter/chromium/src/tools/grit/grit/format/html_inline.py", line 451, in <lambda>
    return re.sub(css_re, lambda m: InlineCSSUrls(m, filepath), text)
  File "/usr/local/google/home/rbpotter/chromium/src/tools/grit/grit/format/html_inline.py", line 458, in InlineCSSUrls
    src_match.group(0))
  File "/usr/lib/python2.7/re.py", line 155, in sub
    return _compile(pattern, flags).sub(repl, string, count)
  File "/usr/local/google/home/rbpotter/chromium/src/tools/grit/grit/format/html_inline.py", line 457, in <lambda>
    lambda m: SrcReplace(m, filepath),
  File "/usr/local/google/home/rbpotter/chromium/src/tools/grit/grit/format/html_inline.py", line 291, in SrcReplace
    filename_expansion_function=filename_expansion_function)
  File "/usr/local/google/home/rbpotter/chromium/src/tools/grit/grit/format/html_inline.py", line 156, in SrcInlineAsDataURL
    inlined_files, names_only)
  File "/usr/local/google/home/rbpotter/chromium/src/tools/grit/grit/format/html_inline.py", line 125, in ConvertFileToDataURL
    'cannot be stored in a data url.' % filename)
Exception: [[destination.icon]] is of an an unknown type and cannot be stored in a data url.
 

Comment 1 by dpa...@chromium.org, Dec 13

Cc: dbeam@chromium.org

Comment 2 by dpa...@chromium.org, Dec 13

The title of this bug is a bit misleading. IIUC, GRIT incorrectly tries to inline URLs that it should ignore.

Comment 3 by rbpotter@chromium.org, Dec 13

Summary: Grit does not ignore polymer bindings when there are multiple url()s in "background: " (was: Grit fails to inline multiple url()s in "background: ")

Comment 4 by dbeam@chromium.org, Dec 13

i feel a negative lookahead in our future...

Comment 5 by dpa...@chromium.org, Dec 13

Or maybe we can stop using flattenhtml from print preview? I am wondering if preprocess=true would be sufficient (and therefore bypass the problem).

Comment 6 by bugdroid1@chromium.org, Dec 15

Project Member
The following revision refers to this bug:
  https://chromium.googlesource.com/chromium/src.git/+/69cba61a73ea5f5f47353836ddfb07bdb29ec3c8

commit 69cba61a73ea5f5f47353836ddfb07bdb29ec3c8
Author: rbpotter <rbpotter@chromium.org>
Date: Sat Dec 15 03:05:14 2018

Grit: Fix Polymer bindings when there are multiple url()s

Also moving all Polymer binding related testing to a separate test in
html_inline_unittest.py, including a new test case for this bug.

Bug:  914591 
Change-Id: I463ada044f827ad3ca31566391984b20a275e993
Reviewed-on: https://chromium-review.googlesource.com/c/1374955
Commit-Queue: Rebekah Potter <rbpotter@chromium.org>
Reviewed-by: Dan Beam <dbeam@chromium.org>
Reviewed-by: Demetrios Papadopoulos <dpapad@chromium.org>
Reviewed-by: Lei Zhang <thestig@chromium.org>
Cr-Commit-Position: refs/heads/master@{#616932}
[modify] https://crrev.com/69cba61a73ea5f5f47353836ddfb07bdb29ec3c8/tools/grit/grit/format/html_inline.py
[modify] https://crrev.com/69cba61a73ea5f5f47353836ddfb07bdb29ec3c8/tools/grit/grit/format/html_inline_unittest.py

Comment 7 by rbpotter@chromium.org, Dec 17

Status: Fixed (was: Assigned)

Sign in to add a comment