Fix wxWebView::RunScript() with string containing backslashes
Escape backslashes in wxJSScriptWrapper to allow strings with backslashes in them to work again -- this was broken while implementing support for returning values from JavaScript to C++. See https://github.com/wxWidgets/wxWidgets/pull/741
This commit is contained in:
		
				
					committed by
					
						
						Vadim Zeitlin
					
				
			
			
				
	
			
			
			
						parent
						
							dd2d62c703
						
					
				
				
					commit
					3d427a1af1
				
			@@ -38,7 +38,7 @@ public:
 | 
			
		||||
 | 
			
		||||
        // Adds one escape level if there is a single quote, double quotes or
 | 
			
		||||
        // escape characters
 | 
			
		||||
        wxRegEx escapeDoubleQuotes("(\\\\*)(['\"\n\r\v\t\b\f])");
 | 
			
		||||
        wxRegEx escapeDoubleQuotes("(\\\\*)([\\'\"\n\r\v\t\b\f])");
 | 
			
		||||
        escapeDoubleQuotes.Replace(&m_escapedCode,"\\1\\1\\\\\\2");
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -323,6 +323,9 @@ void WebTestCase::RunScript()
 | 
			
		||||
    CPPUNIT_ASSERT(m_browser->RunScript("function f(a){return a;}f('Hello World!');", &result));
 | 
			
		||||
    CPPUNIT_ASSERT_EQUAL(_("Hello World!"), result);
 | 
			
		||||
 | 
			
		||||
    CPPUNIT_ASSERT(m_browser->RunScript("function f(a){return a;}f('a\\\'aa\\n\\rb\vb\\tb\\\\ccc\\\"ddd\\b\\fx');", &result));
 | 
			
		||||
    CPPUNIT_ASSERT_EQUAL(_("a\'aa\n\rb\vb\tb\\ccc\"ddd\b\fx"), result);
 | 
			
		||||
 | 
			
		||||
    CPPUNIT_ASSERT(m_browser->RunScript("function f(a){return a;}f(123);", &result));
 | 
			
		||||
    CPPUNIT_ASSERT_EQUAL(123, wxAtoi(result));
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user