@@ -41,6 +41,7 @@ public void loadEngine() {
4141 // Creates and enters a Context. The Context stores information
4242 // about the execution environment of a script.
4343 engine = Context .enter ();
44+ engine .setLanguageVersion (Context .VERSION_ES6 );
4445
4546 // Initialize the standard objects (Object, Function, etc.)
4647 // This must be done before scripts can be executed. Returns
@@ -92,13 +93,14 @@ public String encodeURIComponent(String s) {
9293 // Creates and enters a Context. The Context stores information
9394 // about the execution environment of a script.
9495 engine = Context .enter ();
96+ engine .setLanguageVersion (Context .VERSION_ES6 );
9597
9698 // Initialize the standard objects (Object, Function, etc.)
9799 // This must be done before scripts can be executed. Returns
98100 // a scope object that we use in later calls.
99101 engineScope = engine .initStandardObjects ();
100102 }
101- String scriptStr = String .format ("encodeURIComponent(`%s` )" , s . replace ( " \" " , " \\ \" " ));
103+ String scriptStr = String .format ("encodeURIComponent(%s )" , gson . toJson ( s ));
102104 return engine .evaluateString (engineScope , scriptStr , "<cmd>" , 1 , null ).toString ();
103105 }
104106
@@ -109,7 +111,7 @@ public String getProfile() {
109111
110112 @ Override
111113 public String getHelp (String ruleId , String reasonId , String helpRoot ) {
112- String scriptStr = String .format ("ace_checker.engine.getHelp(`%s`,`%s`,`%s` )" , ruleId , reasonId , helpRoot );
114+ String scriptStr = String .format ("ace_checker.engine.getHelp(%s,%s,%s )" , gson . toJson ( ruleId ), gson . toJson ( reasonId ), gson . toJson ( helpRoot ) );
113115 return engine .evaluateString (engineScope , scriptStr , "<cmd>" , 1 , null ).toString ();
114116 }
115117}
0 commit comments