File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -73,10 +73,13 @@ CSSOM.parse = function parse(token) {
7373
7474 // String
7575 case '"' :
76- index = token . indexOf ( '"' , i + 1 ) + 1 ;
77- if ( ! index ) {
78- parseError ( 'Unmatched "' ) ;
79- }
76+ index = i + 1 ;
77+ do {
78+ index = token . indexOf ( '"' , index ) + 1 ;
79+ if ( ! index ) {
80+ parseError ( 'Unmatched "' ) ;
81+ }
82+ } while ( token [ index - 2 ] === '\\' )
8083 buffer += token . slice ( i , index ) ;
8184 i = index - 1 ;
8285 switch ( state ) {
@@ -90,10 +93,13 @@ CSSOM.parse = function parse(token) {
9093 break ;
9194
9295 case "'" :
93- index = token . indexOf ( "'" , i + 1 ) + 1 ;
94- if ( ! index ) {
95- parseError ( "Unmatched '" ) ;
96- }
96+ index = i + 1 ;
97+ do {
98+ index = token . indexOf ( "'" , index ) + 1 ;
99+ if ( ! index ) {
100+ parseError ( "Unmatched '" ) ;
101+ }
102+ } while ( token [ index - 2 ] === '\\' )
97103 buffer += token . slice ( i , index ) ;
98104 i = index - 1 ;
99105 switch ( state ) {
Original file line number Diff line number Diff line change @@ -956,9 +956,30 @@ describe('parse', function() {
956956 } ) ;
957957 } ) ;
958958
959+ given ( 'a{content:"\\""}' , function ( input ) {
960+ var parsed = CSSOM . parse ( input ) ;
961+ expect ( parsed . cssRules [ 0 ] . style . content ) . toBe ( '"\\""' ) ;
962+ } ) ;
963+
964+ given ( "a{content:'\\''}" , function ( input ) {
965+ var parsed = CSSOM . parse ( input ) ;
966+ expect ( parsed . cssRules [ 0 ] . style . content ) . toBe ( "'\\''" ) ;
967+ } ) ;
968+
969+ given ( 'a{content:"abc\\"\\"d\\"ef"}' , function ( input ) {
970+ var parsed = CSSOM . parse ( input ) ;
971+ expect ( parsed . cssRules [ 0 ] . style . content ) . toBe ( '"abc\\"\\"d\\"ef"' ) ;
972+ } ) ;
973+
974+ given ( "a{content:'abc\\'\\'d\\'ef'}" , function ( input ) {
975+ var parsed = CSSOM . parse ( input ) ;
976+ expect ( parsed . cssRules [ 0 ] . style . content ) . toBe ( "'abc\\'\\'d\\'ef'" ) ;
977+ } ) ;
978+
959979} ) ;
960980} ) ;
961981
982+
962983/**
963984 * Recursively remove all keys which start with '_', except "_vendorPrefix", which needs to be tested against.
964985 * @param {Object } object
You can’t perform that action at this time.
0 commit comments