Skip to content
  • Jeremy Evans's avatar
    11ae581a
    Fix handling of control/meta escapes in literal regexps · 11ae581a
    Jeremy Evans authored
    Ruby uses a recursive algorithm for handling control/meta escapes
    in strings (read_escape).  However, the equivalent code for regexps
    (tokadd_escape) in did not use a recursive algorithm.  Due to this,
    Handling of control/meta escapes in regexp did not have the same
    behavior as in strings, leading to behavior such as the following
    returning nil:
    
    ```ruby
    /\c\xFF/ =~ "\c\xFF"
    ```
    
    Switch the code for handling \c, \C and \M in literal regexps to
    use the same code as for strings (read_escape), to keep behavior
    consistent between the two.
    
    Fixes [Bug #14367]
    11ae581a
    Fix handling of control/meta escapes in literal regexps
    Jeremy Evans authored
    Ruby uses a recursive algorithm for handling control/meta escapes
    in strings (read_escape).  However, the equivalent code for regexps
    (tokadd_escape) in did not use a recursive algorithm.  Due to this,
    Handling of control/meta escapes in regexp did not have the same
    behavior as in strings, leading to behavior such as the following
    returning nil:
    
    ```ruby
    /\c\xFF/ =~ "\c\xFF"
    ```
    
    Switch the code for handling \c, \C and \M in literal regexps to
    use the same code as for strings (read_escape), to keep behavior
    consistent between the two.
    
    Fixes [Bug #14367]
Loading