firefox accepts invalid url() for at least background-image

RESOLVED INVALID

Status

()

Core
CSS Parsing and Computation
RESOLVED INVALID
6 years ago
6 years ago

People

(Reporter: cobexer, Unassigned)

Tracking

14 Branch
x86_64
Linux
Points:
---

Firefox Tracking Flags

(Not tracked)

Details

Attachments

(1 attachment)

(Reporter)

Description

6 years ago
User Agent: Mozilla/5.0 (X11; Linux x86_64; rv:14.0) Gecko/20100101 Firefox/14.0.1
Build ID: 2012071300

Steps to reproduce:

<!doctype html>
<html>
        <head>
        </head>
        <body>
                <div id="test">
                        <h2>background should be green</h2>
                </div>
                <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script>
                <script>
                        var green = 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVQImWNgaGD4DwAChAGA2FJdiQAAAABJRU5ErkJggg==';
                        var red = 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVQImWP4z8DwHwAFAAH/q842iQAAAABJRU5ErkJggg==';
                        $(function() {
                                var $t = $("#test");
                                $t.css('background-image', 'url("' + green + '")');
                                $t.css('background-image', 'url("' + red + '"'); // ) is missing
                        })
                </script>
        </body>
</html>


Actual results:

the second invalid attempt to set the background image is accepted too (IE9 and Chrome 21 both reject it)



Expected results:

background green
should have thrown syntax error ? (not sure i would want that tough)

Comment 1

6 years ago
Created attachment 653837 [details]
Reporter's testcase

Updated

6 years ago
Attachment #653837 - Attachment mime type: text/plain → text/html
Component: Untriaged → Style System (CSS)
Product: Firefox → Core
The spec requires this behavior.  Yes, IE and Chrome get it wrong.

Specifically, see http://www.w3.org/TR/CSS21/syndata.html#parsing-errors under "Unexpected end of style sheet".
Status: UNCONFIRMED → RESOLVED
Last Resolved: 6 years ago
Resolution: --- → INVALID
And note that you don't even need the dynamic stuff.  Just doing:

<style>
  body { background-image: url("something.png"</style>

will trigger the relevant error-handling codepath in UAs that implement the spec properly.
You need to log in before you can comment on or make changes to this bug.