Project

General

Profile

Backport #8076

Lookbehind assertion fails with /m mode enabled

Added by naruse (Yui NARUSE) over 6 years ago. Updated about 6 years ago.

Status:
Closed
Priority:
Normal

Description

Lookbehind assertions fail if they are longer than one character, and if dotall mode is set.

irb(main):001:0> "foo" =~ /(?<=f)./m
=> 1
irb(main):002:0> "foo" =~ /(?<=fo).
/m
=> nil

The latter should have matched the "o". This only seems to happen with dotall mode turned on (dot matches newline); without it, everything is OK:

irb(main):003:0> "foo" =~ /(?<=f)./
=> 1
irb(main):004:0> "foo" =~ /(?<=fo).
/
=> 2


Related issues

Related to Backport200 - Backport #8023: Lookbehind assertion fails with /m mode enabledClosed03/06/2013Actions

Associated revisions

Revision ee09f19f
Added by usa (Usaku NAKAMURA) about 6 years ago

  • regcomp.c (optimize_node_left, set_optimize_info_from_tree): right
    handling for look behind anchor.

  • regexec.c (onig_search): ditto.
    [Backport #8076]

this patch is derived from Onigmo base tree.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_9_3@39983 b2dd03c8-39d4-4d8f-98ff-823fe69b080e

Revision 39983
Added by usa (Usaku NAKAMURA) about 6 years ago

  • regcomp.c (optimize_node_left, set_optimize_info_from_tree): right
    handling for look behind anchor.

  • regexec.c (onig_search): ditto.
    [Backport #8076]

this patch is derived from Onigmo base tree.

History

Updated by k_takata (Ken Takata) over 6 years ago

すみません。上記パッチでは不足していることが分かりました。
https://github.com/k-takata/Onigmo/commit/962464a4dd4a9342febfd3e139d51d4282395b28
の regcomp.c に対するパッチも適用が必要なはずです。
なお、このパッチの regexec.c に対する修正は、 #3568 の修正による最適化の無効化を再度有効にするためのものですが、1.9.3にはそのままでは適用できません。

#3

Updated by usa (Usaku NAKAMURA) about 6 years ago

  • Status changed from Assigned to Closed

This issue was solved with changeset r39983.
Yui, thank you for reporting this issue.
Your contribution to Ruby is greatly appreciated.
May Ruby be with you.


  • regcomp.c (optimize_node_left, set_optimize_info_from_tree): right
    handling for look behind anchor.

  • regexec.c (onig_search): ditto.
    [Backport #8076]

this patch is derived from Onigmo base tree.

Also available in: Atom PDF