Ruby on Rails | Screencasts | Download | Documentation | Weblog | Community | Source

Ticket #9646 (closed defect: fixed)

Opened 1 year ago

Last modified 1 year ago

[PATCH] MultiByte::Chars#slice should support Regexp's

Reported by: yob Assigned to: core
Priority: normal Milestone: 2.x
Component: ActiveSupport Version: edge
Severity: normal Keywords: multibytebugs
Cc:

Description

Currently the slice method for MultiByte::Chars accepts a single Regexp as an argument, but then unpacks the string into an array and passes the Regexp into Array#slice, which fails.

I assume there might be issues relating to slicing a Unicode string with a Regexp so I haven't written a patch that fixes the issue, but I have added a failing test case.

Attachments

test_for_slicing_by_regexp.diff (1.8 kB) - added by yob on 09/24/07 14:49:06.
replace first patch with one that has a suggested fix and improved test
fix_for_slicing_by_regexp.diff (2.1 kB) - added by yob on 09/24/07 23:23:07.
allow MultiByte::Char objects to be sliced with a regexp
fix_for_slicing_by_regexp.20071015.diff (2.1 kB) - added by yob on 10/15/07 04:50:17.

Change History

09/24/07 14:49:06 changed by yob

  • attachment test_for_slicing_by_regexp.diff added.

replace first patch with one that has a suggested fix and improved test

09/24/07 16:10:14 changed by manfred

  • keywords set to multibytebugs.

Cool, looks like a good way to fix it. Can you add tests for the following, and maybe some more edge cases you can think of?

@string.slice(/unknown/u)
@string.slice(/(ffi)/u, 2)

They should both return nil.

09/24/07 23:23:07 changed by yob

  • attachment fix_for_slicing_by_regexp.diff added.

allow MultiByte::Char objects to be sliced with a regexp

10/15/07 04:00:53 changed by bitsweat

  • status changed from new to closed.
  • resolution set to incomplete.

I tried to test this patch but it doesn't apply against trunk. Could you update?

10/15/07 04:50:17 changed by yob

  • attachment fix_for_slicing_by_regexp.20071015.diff added.

10/15/07 04:51:39 changed by yob

  • status changed from closed to reopened.
  • resolution deleted.

I just updated the patch against trunk, but there wasn't any change.

I'm pulling trunk from http://svn.rubyonrails.org/rails - is that correct? What was the error?

10/15/07 07:36:04 changed by bitsweat

My fault, bad paste :) Sorry.

10/15/07 07:38:56 changed by bitsweat

  • status changed from reopened to closed.
  • resolution set to fixed.

(In [7910]) Multibyte: String#slice supports regexp argument. Closes #9646.