[ruby-dev:50030] [Ruby trunk Bug#13352] RegExp infinite looping

From: jumnichi.kose@...
Date: 2017-03-22 05:36:14 UTC
List: ruby-dev #50030
Issue #13352 has been updated by jumnichi_kose (=E5=B0=8F=E7=80=AC =E6=B7=
=B3=E4=B8=80).


=E6=AD=A3=E8=A6=8F=E8=A1=A8=E7=8F=BE=E3=83=A9=E3=82=A4=E3=83=96=E3=83=A9=E3=
=83=AA=E3=81=AE=E5=85=B1=E9=80=9A=E7=9A=84=E3=81=AA=E5=95=8F=E9=A1=8C=E3=81=
=8B=E3=82=82=E3=81=97=E3=82=8C=E3=81=AA=E3=81=84=E3=81=8C=E3=80=81=E7=9A=86=
=E3=81=95=E3=82=93=E3=81=AE=E5=BD=B1=E9=9F=BF=E5=8A=9B=E3=82=92=E8=A1=8C=E4=
=BD=BF=E3=81=97=E3=81=A6=E3=80=81=E6=94=B9=E5=96=84=E3=81=95=E3=82=8C=E3=82=
=8B=E3=81=93=E3=81=A8=E3=82=92=E5=B8=8C=E6=9C=9B=E3=81=97=E3=81=BE=E3=81=99=
=E3=80=82
=E5=B0=91=E3=81=AA=E3=81=8F=E3=81=A8=E3=82=82rexEx.compile=E3=81=A7=E3=81=
=AF=E3=80=81=E4=B8=8E=E3=81=88=E3=81=9F=E6=AD=A3=E8=A6=8F=E8=A1=A8=E7=8F=BE=
=E3=81=AE=E4=B8=8D=E6=AD=A3=E3=82=92=E6=91=98=E5=87=BA=E3=81=97=E3=81=A6=E6=
=AC=B2=E3=81=97=E3=81=84=E3=81=A8=E6=80=9D=E3=81=84=E3=81=BE=E3=81=99=E3=80=
=82

----------------------------------------
Bug #13352: RegExp infinite looping
https://bugs.ruby-lang.org/issues/13352#change-63720

* Author: jumnichi_kose (=E5=B0=8F=E7=80=AC =E6=B7=B3=E4=B8=80)
* Status: Open
* Priority: Normal
* Assignee:=20
* Target version:=20
* ruby -v: 2.3.3p222 (2016-11-21 revision 56859) [x64-mingw32],  ruby 2.2.4=
p230 (2015-12-16 revision 53155) [i386-mingw32]
* Backport: 2.2: UNKNOWN, 2.3: UNKNOWN, 2.4: UNKNOWN
----------------------------------------
ruby entered an infinite loop with the following three steps.

~~~ ruby
r =3D /(?=3D\W)\W?(?:(?:(?:\/\*<)?[\'\"]?([\w_\$]+)[\'\"]?(?:>\*\/\s+this)?=
|(this))\.(\$scope|json)|([\'\"](?:\$scope|json)[\'\"]))((\.)(inputObjects)=
|(\.)(spreadSheets)(?:\.[\'\"]?([^\.\'\"\|\s,]+)[\'\"]?|\[[\'\"]?((?:[^\'\"=
\]\[]*|\[[^\]]*\])*)[\'\"]?\])(\.)(model))\s*(?:\.[\'\"]?([^\.\'\"\|\s,]+)[=
\'\"]?|\[[\'\"]?((?:[^\'\"\]\[]*|\[[^\]]*\])*)[\'\"]?\])/
txt =3D ".model |,| 'anController'.$scope.inputObjects['fieldName .../* !! =
comment ...*/"
txt.scan r
~~~

Node.js also falls into an infinite loop.
~~~ javascript
var r =3D /(?=3D\W)\W?(?:(?:(?:\/\*<)?[\'\"]?([\w_\$]+)[\'\"]?(?:>\*\/\s+th=
is)?|(this))\.(\$scope|json)|([\'\"](?:\$scope|json)[\'\"]))((\.)(inputObje=
cts)|(\.)(spreadSheets)(?:\.[\'\"]?([^\.\'\"\|\s,]+)[\'\"]?|\[[\'\"]?((?:[^=
\'\"\]\[]*|\[[^\]]*\])*)[\'\"]?\])(\.)(model))\s*(?:\.[\'\"]?([^\.\'\"\|\s,=
]+)[\'\"]?|\[[\'\"]?((?:[^\'\"\]\[]*|\[[^\]]*\])*)[\'\"]?\])/
var txt =3D ".model |,| 'anController'.$scope.inputObjects['fieldName .../*=
 !! comment ...*/"

var s =3Dr.exec (txt)

console.log(s)


~~~





--=20
https://bugs.ruby-lang.org/

In This Thread

Prev Next