File tree Expand file tree Collapse file tree 2 files changed +16
-0
lines changed Expand file tree Collapse file tree 2 files changed +16
-0
lines changed Original file line number Diff line number Diff line change @@ -2407,6 +2407,21 @@ def test_template_function_and_flag_is_deprecated(self):
2407
2407
self .assertTrue (template_re1 .match ('ahoy' ))
2408
2408
self .assertFalse (template_re1 .match ('nope' ))
2409
2409
2410
+ def test_regression_gh94675 (self ):
2411
+ start = time .perf_counter ()
2412
+ pattern = re .compile (r'(?<=[({}])(((//[^\n]*)?[\n])([\000-\040])*)*'
2413
+ r'((/[^/\[\n]*(([^\n]|(\[\n]*(]*)*\]))'
2414
+ r'[^/\[]*)*/))((((//[^\n]*)?[\n])'
2415
+ r'([\000-\040]|(/\*[^*]*\*+'
2416
+ r'([^/*]\*+)*/))*)+(?=[^\000-\040);\]}]))' )
2417
+ input_js = '''a(function() {
2418
+ ///////////////////////////////////////////////////////////////////
2419
+ });'''
2420
+ _ = pattern .sub ('' , input_js )
2421
+ t = time .perf_counter () - start
2422
+ # Without optimization it takes 0.017 second on my computer.
2423
+ self .assertLess (t , 0.5 )
2424
+
2410
2425
2411
2426
def get_debug_out (pat ):
2412
2427
with captured_stdout () as out :
Original file line number Diff line number Diff line change
1
+ Add a regreesion test for :mod: `re ` exponencional slowdon when using rjsmin.
You can’t perform that action at this time.
0 commit comments