Преглед на файлове

Merge pull request #791 from weseek/fix/xss-code-blocks-20190109

fix xss caused by detach-code-blocks
Yuki Takei преди 7 години
родител
ревизия
2b3c214ea7
променени са 1 файла, в които са добавени 2 реда и са изтрити 2 реда
  1. 2 2
      src/client/js/util/interceptor/detach-code-blocks.js

+ 2 - 2
src/client/js/util/interceptor/detach-code-blocks.js

@@ -50,8 +50,8 @@ export class DetachCodeBlockInterceptor extends BasicInterceptor {
 
 
     context.dcbContextMap = {};
     context.dcbContextMap = {};
 
 
-    // see: https://regex101.com/r/8PAEcC/4
-    context[targetKey] = context[targetKey].replace(/((```|~~~)(.|[\r\n])*?(```|~~~))|(`[^\r\n]*?`)|(<pre>(.|[\r\n])*?<\/pre>)|(<pre\s[^>]*>(.|[\r\n])*?<\/pre>)/gm, (all) => {
+    // see: https://regex101.com/r/8PAEcC/5
+    context[targetKey] = context[targetKey].replace(/(^(```|~~~)(.|[\r\n])*?(```|~~~)$)|(`[^\r\n]*?`)|(<pre>(.|[\r\n])*?<\/pre>)|(<pre\s[^>]*>(.|[\r\n])*?<\/pre>)/gm, (all) => {
       // create ID
       // create ID
       const replaceId = 'dcb-' + this.createRandomStr(8);
       const replaceId = 'dcb-' + this.createRandomStr(8);
       this.logger.debug(`'replaceId'=${replaceId} : `, all);
       this.logger.debug(`'replaceId'=${replaceId} : `, all);