@@ -261,14 +261,46 @@ public void ShouldHandleQueryParams(bool withOverriddenPath)
261261
262262 if ( withOverriddenPath )
263263 {
264- mocks . Engine . Verify ( x => x . Evaluate < string > ( @"ReactDOMServer.renderToString(React.createElement(ComponentName, Object.assign({}, { location: ' /test2?b=1&c=2' , context: context })))" ) ) ;
264+ mocks . Engine . Verify ( x => x . Evaluate < string > ( @"ReactDOMServer.renderToString(React.createElement(ComponentName, Object.assign({}, { location: "" /test2?b=1&c=2"" , context: context })))" ) ) ;
265265 }
266266 else
267267 {
268- mocks . Engine . Verify ( x => x . Evaluate < string > ( @"ReactDOMServer.renderToString(React.createElement(ComponentName, Object.assign({}, { location: ' /test?a=1&b=2' , context: context })))" ) ) ;
268+ mocks . Engine . Verify ( x => x . Evaluate < string > ( @"ReactDOMServer.renderToString(React.createElement(ComponentName, Object.assign({}, { location: "" /test?a=1&b=2"" , context: context })))" ) ) ;
269269 }
270270 }
271271
272+ [ Theory ]
273+ [ InlineData ( "?a='\" 1" , "?a='\\ \" 1" ) ]
274+ public void ShouldEscapeQuery ( string query , string expected )
275+ {
276+ var mocks = ConfigureMockReactEnvironment ( ) ;
277+ ConfigureMockConfiguration ( ) ;
278+ ConfigureReactIdGenerator ( ) ;
279+
280+ mocks . Engine . Setup ( x => x . Evaluate < string > ( "JSON.stringify(context);" ) )
281+ . Returns ( "{ status: 200 }" ) ;
282+
283+ var requestMock = new Mock < HttpRequestBase > ( ) ;
284+ requestMock . SetupGet ( x => x . Path ) . Returns ( "/test" ) ;
285+ var queryStringMock = new Mock < NameValueCollection > ( ) ;
286+ queryStringMock . Setup ( x => x . ToString ( ) ) . Returns ( query ) ;
287+ requestMock . SetupGet ( x => x . QueryString ) . Returns ( queryStringMock . Object ) ;
288+
289+ var htmlHelperMock = new HtmlHelperMocks ( requestMock . Object ) ;
290+
291+ var result = HtmlHelperExtensions . ReactRouter (
292+ htmlHelper : htmlHelperMock . htmlHelper . Object ,
293+ componentName : "ComponentName" ,
294+ props : new { } ,
295+ path : null ,
296+ contextHandler : ( response , context ) => response . StatusCode = context . status . Value
297+ ) ;
298+
299+ htmlHelperMock . httpResponse . VerifySet ( x => x . StatusCode = 200 ) ;
300+
301+ mocks . Engine . Verify ( x => x . Evaluate < string > ( @"ReactDOMServer.renderToString(React.createElement(ComponentName, Object.assign({}, { location: ""/test" + expected + @""", context: context })))" ) ) ;
302+ }
303+
272304 [ Fact ]
273305 public void ShouldRedirectPermanent ( )
274306 {
0 commit comments