plainheart commented on code in PR #21871:
URL: https://github.com/apache/echarts/pull/21871#discussion_r4798863678


##########
dist/echarts.js:
##########


Review Comment:
   It seems the dist files should not be committed for now.



##########
src/visual/aria.ts:
##########
@@ -254,9 +254,11 @@ function ariaVisual(ecModel: GlobalModel, api: 
ExtensionAPI) {
 
         let result = str;
         zrUtil.each(keyValues, function (value: string, key: string) {
-            result = result.replace(
+            result = zrUtil.stringReplace(
+                result,
                 new RegExp('\\{\\s*' + key + '\\s*\\}', 'g'),

Review Comment:
   Besides the `replacer` issue (which we have fixed), I noticed there may be 
another long-term potential security risk, that is, we are creating a `RegExp` 
from direct user input.
   
   I think the `key` needs to be escaped for security. For example,
   
   ```ts
   export const escapeRegExp= (function () {
       if (typeof RegExp.escape === 'function') {
           return RegExp.escape;
       }
       const escapeReg = /[.*+?^${}()|[\]\\]/g;
       return function (str: string): string {
           return str.replace(escapeReg, '\\$&');
       };
   })();
   
   result = zrUtil.stringReplace(result, new RegExp('\\{\\s*' + 
escapeRegExp(key)+ '\\s*\\}', 'g'), () => value);
   ```



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to