From: jumnichi.kose@... Date: 2017-03-22T05:36:14+00:00 Subject: [ruby-dev:50030] [Ruby trunk Bug#13352] RegExp infinite looping Issue #13352 has been updated by jumnichi_kose (小瀬 淳一). 正規表現ライブラリの共通的な問題かもしれないが、皆さんの影響力を行使して、改善されることを希望します。 少なくともrexEx.compileでは、与えた正規表現の不正を摘出して欲しいと思います。 ---------------------------------------- Bug #13352: RegExp infinite looping https://bugs.ruby-lang.org/issues/13352#change-63720 * Author: jumnichi_kose (小瀬 淳一) * Status: Open * Priority: Normal * Assignee: * Target version: * ruby -v: 2.3.3p222 (2016-11-21 revision 56859) [x64-mingw32], ruby 2.2.4p230 (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 = /(?=\W)\W?(?:(?:(?:\/\*<)?[\'\"]?([\w_\$]+)[\'\"]?(?:>\*\/\s+this)?|(this))\.(\$scope|json)|([\'\"](?:\$scope|json)[\'\"]))((\.)(inputObjects)|(\.)(spreadSheets)(?:\.[\'\"]?([^\.\'\"\|\s,]+)[\'\"]?|\[[\'\"]?((?:[^\'\"\]\[]*|\[[^\]]*\])*)[\'\"]?\])(\.)(model))\s*(?:\.[\'\"]?([^\.\'\"\|\s,]+)[\'\"]?|\[[\'\"]?((?:[^\'\"\]\[]*|\[[^\]]*\])*)[\'\"]?\])/ txt = ".model |,| 'anController'.$scope.inputObjects['fieldName .../* !! comment ...*/" txt.scan r ~~~ Node.js also falls into an infinite loop. ~~~ javascript var r = /(?=\W)\W?(?:(?:(?:\/\*<)?[\'\"]?([\w_\$]+)[\'\"]?(?:>\*\/\s+this)?|(this))\.(\$scope|json)|([\'\"](?:\$scope|json)[\'\"]))((\.)(inputObjects)|(\.)(spreadSheets)(?:\.[\'\"]?([^\.\'\"\|\s,]+)[\'\"]?|\[[\'\"]?((?:[^\'\"\]\[]*|\[[^\]]*\])*)[\'\"]?\])(\.)(model))\s*(?:\.[\'\"]?([^\.\'\"\|\s,]+)[\'\"]?|\[[\'\"]?((?:[^\'\"\]\[]*|\[[^\]]*\])*)[\'\"]?\])/ var txt = ".model |,| 'anController'.$scope.inputObjects['fieldName .../* !! comment ...*/" var s =r.exec (txt) console.log(s) ~~~ -- https://bugs.ruby-lang.org/