fix(runtime): 添加避免零宽度匹配的无限循环

This commit is contained in:
wxzhang 2023-03-30 08:52:09 +08:00
parent 6ffdc10814
commit a67f0568f0

View File

@ -105,6 +105,10 @@ function forEachInterpolatedVars(str, replacer, options = {}) {
let opts = Object.assign({replaceAll: true },options);
varWithPipeRegexp.lastIndex = 0;
while ((matched = varWithPipeRegexp.exec(result)) !== null) {
// 这对于避免零宽度匹配的无限循环是必要的
if (matched.index === varWithPipeRegexp.lastIndex) {
varWithPipeRegexp.lastIndex++;
}
const varname = matched[1] || "";
// 解析格式化器和参数 = [<formatterName>,[<formatterName>,[<arg>,<arg>,...]]]
const formatters = parseFormatters(matched[2] || "");