File tree Expand file tree Collapse file tree 2 files changed +35
-8
lines changed Expand file tree Collapse file tree 2 files changed +35
-8
lines changed Original file line number Diff line number Diff line change @@ -73,10 +73,13 @@ CSSOM.parse = function parse(token) {
73
73
74
74
// String
75
75
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 ] === '\\' )
80
83
buffer += token . slice ( i , index ) ;
81
84
i = index - 1 ;
82
85
switch ( state ) {
@@ -90,10 +93,13 @@ CSSOM.parse = function parse(token) {
90
93
break ;
91
94
92
95
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 ] === '\\' )
97
103
buffer += token . slice ( i , index ) ;
98
104
i = index - 1 ;
99
105
switch ( state ) {
Original file line number Diff line number Diff line change @@ -956,9 +956,30 @@ describe('parse', function() {
956
956
} ) ;
957
957
} ) ;
958
958
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
+
959
979
} ) ;
960
980
} ) ;
961
981
982
+
962
983
/**
963
984
* Recursively remove all keys which start with '_', except "_vendorPrefix", which needs to be tested against.
964
985
* @param {Object } object
You can’t perform that action at this time.
0 commit comments