* [ruby-dev:50029] [Ruby trunk Bug#13352] RegExp infinite looping
[not found] <redmine.issue-13352.20170322053236@ruby-lang.org>
@ 2017-03-22 5:32 ` jumnichi.kose
2017-03-22 5:36 ` [ruby-dev:50030] " jumnichi.kose
` (3 subsequent siblings)
4 siblings, 0 replies; 5+ messages in thread
From: jumnichi.kose @ 2017-03-22 5:32 UTC (permalink / raw
To: ruby-dev
Issue #13352 has been reported by jumnichi_kose (小瀬 淳一).
----------------------------------------
Bug #13352: RegExp infinite looping
https://bugs.ruby-lang.org/issues/13352
* 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/
^ permalink raw reply [flat|nested] 5+ messages in thread
* [ruby-dev:50030] [Ruby trunk Bug#13352] RegExp infinite looping
[not found] <redmine.issue-13352.20170322053236@ruby-lang.org>
2017-03-22 5:32 ` [ruby-dev:50029] [Ruby trunk Bug#13352] RegExp infinite looping jumnichi.kose
@ 2017-03-22 5:36 ` jumnichi.kose
2017-03-22 10:55 ` [ruby-dev:50031] " duerst
` (2 subsequent siblings)
4 siblings, 0 replies; 5+ messages in thread
From: jumnichi.kose @ 2017-03-22 5:36 UTC (permalink / raw
To: ruby-dev
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/
^ permalink raw reply [flat|nested] 5+ messages in thread
* [ruby-dev:50031] [Ruby trunk Bug#13352] RegExp infinite looping
[not found] <redmine.issue-13352.20170322053236@ruby-lang.org>
2017-03-22 5:32 ` [ruby-dev:50029] [Ruby trunk Bug#13352] RegExp infinite looping jumnichi.kose
2017-03-22 5:36 ` [ruby-dev:50030] " jumnichi.kose
@ 2017-03-22 10:55 ` duerst
2017-03-22 13:27 ` [ruby-dev:50033] [Ruby trunk Bug#13352][Rejected] " naruse
2017-03-23 0:49 ` [ruby-dev:50035] [Ruby trunk Bug#13352] " jumnichi.kose
4 siblings, 0 replies; 5+ messages in thread
From: duerst @ 2017-03-22 10:55 UTC (permalink / raw
To: ruby-dev
Issue #13352 has been updated by duerst (Martin Dürst).
I haven't yet had time to analyze the regular expression in detail. Are you sure this is really an infinite loop, and not just a case of exponentially slow processing (e.g. similar to stackoverflow.com/questions/16580665/node-js-regex-engine-fails-on-large-input)?
----------------------------------------
Bug #13352: RegExp infinite looping
https://bugs.ruby-lang.org/issues/13352#change-63729
* 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/
^ permalink raw reply [flat|nested] 5+ messages in thread
* [ruby-dev:50033] [Ruby trunk Bug#13352][Rejected] RegExp infinite looping
[not found] <redmine.issue-13352.20170322053236@ruby-lang.org>
` (2 preceding siblings ...)
2017-03-22 10:55 ` [ruby-dev:50031] " duerst
@ 2017-03-22 13:27 ` naruse
2017-03-23 0:49 ` [ruby-dev:50035] [Ruby trunk Bug#13352] " jumnichi.kose
4 siblings, 0 replies; 5+ messages in thread
From: naruse @ 2017-03-22 13:27 UTC (permalink / raw
To: ruby-dev
Issue #13352 has been updated by naruse (Yui NARUSE).
Status changed from Open to Rejected
323字目の * を削ってください。
```
(?=\W)\W?(?:(?:(?:\/\*<)?[\'\"]?([\w_\$]+)[\'\"]?(?:>\*\/\s+this)?|(this))\.(\$scope|json)|([\'\"](?:\$scope|json)[\'\"]))((\.)(inputObjects)|(\.)(spreadSheets)(?:\.[\'\"]?([^\.\'\"\|\s,]+)[\'\"]?|\[[\'\"]?((?:[^\'\"\]\[]*|\[[^\]]*\])*)[\'\"]?\])(\.)(model))\s*(?:\.[\'\"]?([^\.\'\"\|\s,]+)[\'\"]?|\[[\'\"]?((?:[^\'\"\]\[]|\[[^\]]*\])*)[\'\"]?\])
```
正規表現の解析には例えば以下のサイトを使うことが出来ます。
https://regex101.com/
この類の正規表現を検出するのはトレードオフがあるのでRubyもnodeも標準では難しいと思いますが、
nodeならば例えば https://github.com/uhop/node-re2 だとこの問題を回避できます。
----------------------------------------
Bug #13352: RegExp infinite looping
https://bugs.ruby-lang.org/issues/13352#change-63730
* Author: jumnichi_kose (小瀬 淳一)
* Status: Rejected
* 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/
^ permalink raw reply [flat|nested] 5+ messages in thread
* [ruby-dev:50035] [Ruby trunk Bug#13352] RegExp infinite looping
[not found] <redmine.issue-13352.20170322053236@ruby-lang.org>
` (3 preceding siblings ...)
2017-03-22 13:27 ` [ruby-dev:50033] [Ruby trunk Bug#13352][Rejected] " naruse
@ 2017-03-23 0:49 ` jumnichi.kose
4 siblings, 0 replies; 5+ messages in thread
From: jumnichi.kose @ 2017-03-23 0:49 UTC (permalink / raw
To: ruby-dev
Issue #13352 has been updated by jumnichi_kose (小瀬 淳一).
Thank' to @naruse
> https://regex101.com/
Your's workaround is fine.
It OK that "Somewhere in my regular expression was bad".
But,I do not understand what was wrong with my RexExp.
A similar regular expression does not fall into an infinite loop.
~~~ ruby
r = /\[((?:[^none of\]]*|other)*)\]/
a="[data]"
a[0...(-2)].scan r # => []
a.scan r # => [["data"]]
~~~
The other workaround was to not use "none of".
~~~ ruby
r = /(?=\W)\W?(?:(?:(?:\/\*<)?[\'\"]?([\w_\$]+)[\'\"]?(?:>\*\/\s+this)?|(this))\.(\$scope|json)|([\'\"](?:\$scope|json)[\'\"]))((\.)(inputObjects)|(\.)(spreadSheets)(?:\.[\'\"]?([\w_\$]+)[\'\"]?|\[[\'\"]?((?:[\w\s(\.)+\-\/_|!]*|\[[\w\s(\.)+\-\/_|!]\])*)[\'\"]?\])(\.)(model))\s*(?:\.[\'\"]?([\w_\$]+)[\'\"]?|\[[\'\"]?((?:[\w\s(\.)+\-\/_|!]+|\[[\w\s(\.)+\-\/_|!]*\]|\/\*[\w\s(\.)+\-\/_|!]+\*\/)+)[\'\"]?\])/
txt = ".model |,| 'anController'.$scope.inputObjects['fieldName .../* !! comment ...*/]"
txt.scan r # => [["anController", nil, "$scope", nil, ".inputObjects", ".", "inputObjects", nil, nil, nil, nil, nil, nil, nil, "fieldName .../* !! comment ...*/"]]
txt[0..(-2)].scan # => []
~~~
I am glad when the site that is explained where is wrong is introduced.
----------------------------------------
Bug #13352: RegExp infinite looping
https://bugs.ruby-lang.org/issues/13352#change-63738
* Author: jumnichi_kose (小瀬 淳一)
* Status: Rejected
* 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/
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2017-03-23 0:15 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <redmine.issue-13352.20170322053236@ruby-lang.org>
2017-03-22 5:32 ` [ruby-dev:50029] [Ruby trunk Bug#13352] RegExp infinite looping jumnichi.kose
2017-03-22 5:36 ` [ruby-dev:50030] " jumnichi.kose
2017-03-22 10:55 ` [ruby-dev:50031] " duerst
2017-03-22 13:27 ` [ruby-dev:50033] [Ruby trunk Bug#13352][Rejected] " naruse
2017-03-23 0:49 ` [ruby-dev:50035] [Ruby trunk Bug#13352] " jumnichi.kose
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).