Project

General

Profile

Actions

Bug #5126

closed

Unicode character classes interpolated into regex throws exception

Added by xaviershay (Xavier Shay) over 12 years ago. Updated over 12 years ago.

Status:
Closed
Assignee:
-
Target version:
ruby -v:
ruby 1.9.3dev (2011-07-31 revision 32789) [x86_64-darwin10.7.0]
Backport:
[ruby-core:38635]

Description

The following script runs under 1.9.2-p290:

# encoding: UTF-8
letter = '\p{L}'
atext = "[#{letter}]"
/#{atext}/

Under 1.9.3-preview1 it raises an exception:

test.rb:6:in `<main>': invalid character property name {L}: /[\p{L}]/ (RegexpError)

The interpolation is necessary to reproduce this bug, unicode character classes work fine when entered directly into the regex.

JRuby has a similar bug: http://jira.codehaus.org/browse/JRUBY-5622

This technique is used in datamapper to build a regex for matching emails:
https://github.com/datamapper/dm-validations/blob/master/lib/dm-validations/formats/email.rb


Related issues 1 (0 open1 closed)

Has duplicate Backport193 - Backport #5287: 1.9.3 - Interpolation in a string causes the string's encoding to be set to ASCII-8BITClosednaruse (Yui NARUSE)09/07/2011Actions
Actions #1

Updated by naruse (Yui NARUSE) over 12 years ago

  • Status changed from Open to Closed
  • % Done changed from 0 to 100

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


Actions

Also available in: Atom PDF

Like0
Like0