File tree Expand file tree Collapse file tree 1 file changed +19
-1
lines changed Expand file tree Collapse file tree 1 file changed +19
-1
lines changed Original file line number Diff line number Diff line change @@ -40,7 +40,25 @@ const App = () => {
40
40
const field = document . getElementById ( 'feed-post-filters-conditions' ) ;
41
41
if ( field && field . value ) {
42
42
const parsedConditions = JSON . parse ( field . value ) ;
43
- setConditions ( parsedConditions && parsedConditions . conditions ? parsedConditions : { conditions : [ ] , match : 'all' } ) ;
43
+ if ( parsedConditions && parsedConditions . conditions ) {
44
+ parsedConditions . conditions = parsedConditions . conditions . map ( condition => {
45
+ // We do all these schananigans to make sure we JS doesn't confuse regex for special characters.
46
+ if ( typeof condition . value === 'string' ) {
47
+ condition . value = condition . value
48
+ . replace ( / \u0008 / g, '\\b' )
49
+ . replace ( / \u000C / g, '\\f' )
50
+ . replace ( / \n / g, '\\n' )
51
+ . replace ( / \r / g, '\\r' )
52
+ . replace ( / \t / g, '\\t' ) ;
53
+ }
54
+ return condition ;
55
+ } ) ;
56
+ setConditions ( parsedConditions ) ;
57
+ } else {
58
+ setConditions ( { conditions : [ ] , match : 'all' } ) ;
59
+ }
60
+ } else {
61
+ setConditions ( { conditions : [ ] , match : 'all' } ) ;
44
62
}
45
63
} , [ ] ) ;
46
64
You can’t perform that action at this time.
0 commit comments