View Issue Details

IDProjectCategoryView StatusLast Update
0030650RunnerHTML5Public2019-05-08 15:14
ReporterYellowAfterlifeAssigned ToAntanas Budvytis 
PriorityLowSeverityA - Crash/HangReproducibility100%
Status ClosedResolutionFixed 
PlatformWindowsOSWindows 10 ProOS Version>=1703
Product Version 
Target Version2.2.3Fixed in Version2.2.3 
Summary0030650: HTML5: string_replace_all(_, "", _) softlocks
DescriptionZero-length search string means that the loop can't advance
Tagsfunctions, html5, Runner
1.4 Found In
2.x Runtime Found In9.9.1.1379
2.x Runtime Verified In9.9.1.1431

Activities

YellowAfterlife

2019-03-28 06:46

Developer  

a_bug.yyz (19,074 bytes)

YellowAfterlife

2019-03-28 06:51

Developer   ~0063554

While we are here, I would like to propose to replace string_replace_all with an indexOf-based implementation, as following

function string_replace_all(s, a, b) {
    if (!a) return s;
    var n = a.length, r = "", i = s.indexOf(a), k = 0;
    while (i >= 0) {
        r += s.substring(k, i) + b;
        k = i + n;
        i = s.indexOf(a, k);
    }
    return k > 0 ? r + s.substring(k) : s;
}

From a small test, this seems to consistently perform better than manually looping over the string and comparing substrings (to exact same effect)

a_fix.yyz (1,030,926 bytes)

Antanas Budvytis

2019-04-10 11:51

Developer   ~0063603

Fixed & implemented Yellow's improved algorithm.