Commit 49ed7328 by Don Mitchell

JS regex's need to escape special chars

LMS-11260
parent 4465b26a
......@@ -35,8 +35,9 @@ window.rewriteStaticLinks = function(content, from, to) {
}
// change all relative urls only which may be embedded inside other tags in content.
// handle http and https
// note: add other protocols here
var regex = new RegExp("(https?:\/\/(www\.)?[-a-zA-Z0-9@:%._\+~#=]{2,256}\.[a-z]{2,6}([-a-zA-Z0-9@:%_\+.~#?&//=]*))?"+from, 'g');
// escape all regex interpretable chars
fromRe = from.replace(/[-\/\\^$*+?.()|[\]{}]/g, '\\$&');
var regex = new RegExp("(https?:\/\/(www\.)?[-a-zA-Z0-9@:%._\+~#=]{2,256}\.[a-z]{2,6}([-a-zA-Z0-9@:%_\+.~#?&//=]*))?"+fromRe, 'g');
return content.replace(regex, replacer);
};
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment