fixup! TF-4224 Reduce ReDoS vulnerability
This commit is contained in:
@@ -361,23 +361,9 @@ void main() {
|
||||
group('Regex initialization optimization', () {
|
||||
test('regex patterns should be reused, not recreated', () {
|
||||
// This test verifies that regex patterns are static and reused
|
||||
// We can't directly test if they're the same object, but we can
|
||||
// verify performance doesn't degrade with multiple calls
|
||||
|
||||
const iterations = 1000;
|
||||
final stopwatch = Stopwatch()..start();
|
||||
|
||||
for (var i = 0; i < iterations; i++) {
|
||||
StringConvert.isTextTable('| a | b |\n|---|---|\n| c | d |');
|
||||
HtmlUtils.wrapPlainTextLinks('<p>https://example.com</p>');
|
||||
StringConvert.extractEmailAddress('test@example.com, test2@example.com');
|
||||
}
|
||||
|
||||
stopwatch.stop();
|
||||
|
||||
// If regex patterns were being recreated each time, this would be much slower
|
||||
expect(stopwatch.elapsedMilliseconds, lessThan(500),
|
||||
reason: 'Multiple calls should be fast due to regex reuse');
|
||||
final regex1 = StringConvert.base64ValidationRegex;
|
||||
final regex2 = StringConvert.base64ValidationRegex;
|
||||
expect(identical(regex1, regex2), true);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user