You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
We've recently found that there are cases where the matches returned from the same exec call are non-deterministic. Sometimes a part of the result is truncated, and sometimes it returns special characters that were not in the original input string.
Here's an example script that runs the same value through 1 million times and prints when the output is unexpected. I've run this several times and have also provided some sample output below. It fails on v1.21.2 and 1.21.3, but succeeds on 1.21.1, 1.21.0 and 1.20.9.
const RE2 = require('re2');
// Regex from RFC https://www.rfc-editor.org/rfc/rfc2396#appendix-B
const URL_RFC_PATTERN = new RE2('^(([^:/?#]+):)?(//([^/?#]*))?([^?#]*)(\\?([^#]*))?(#(.*))?');
function parseUrl(str) {
const matches = URL_RFC_PATTERN.exec(str);
const rv = {
part1: matches[2],
part2: matches[4],
};
return rv;
}
for (let i = 0; i < 1000000; i++) {
const result = parseUrl('https://my-random-example.site/');
if (result.part1 !== 'https') {
console.log('Unexpected result for part1 on attempt #' + i + ': ' + result.part1);
}
if (result.part2 !== 'my-random-example.site') {
console.log('Unexpected result for part2 on attempt #' + i + ': ' + result.part2);
}
}
Sample output:
$ node repro.js
Unexpected result for part1 on attempt #1396: `��)�
Unexpected result for part2 on attempt #1396: ~m-example.site
Unexpected result for part2 on attempt #2528: om-example.site
Unexpected result for part1 on attempt #844837: ���)�
Unexpected result for part2 on attempt #844837: m-example.site
The text was updated successfully, but these errors were encountered:
We've recently found that there are cases where the matches returned from the same
exec
call are non-deterministic. Sometimes a part of the result is truncated, and sometimes it returns special characters that were not in the original input string.Here's an example script that runs the same value through 1 million times and prints when the output is unexpected. I've run this several times and have also provided some sample output below. It fails on v1.21.2 and 1.21.3, but succeeds on 1.21.1, 1.21.0 and 1.20.9.
Sample output:
The text was updated successfully, but these errors were encountered: