This project is archived and is in readonly mode.
ActiveSupport::Multibyte::Chars
Reported by Steve St. Martin | August 10th, 2009 @ 12:05 AM | in 2.3.4
ActiveSupport::Multibyte::Chars does not support rindex() , this creates a bug in truncate when using multibyte strings and options[:seperator]
completion of ticket #2582 depends on this, also causes breakage in 3.0 implementation.
Comments and changes to this ticket
-
Jeremy Kemper August 10th, 2009 @ 02:54 AM
- Assigned user set to Jeremy Kemper
- State changed from new to open
- Milestone set to 2.3.4
Good catch. Could you use
git format-patch
instead of diff? -
Elad Meidar August 10th, 2009 @ 02:59 AM
- Assigned user cleared.
"Patch does not have a valid email address", attached a working patch.
-
Jeremy Kemper August 10th, 2009 @ 03:07 AM
- Assigned user set to Jeremy Kemper
On Ruby 1.9:
1) Failure: test_rindex_should_return_character_offset(MultibyteCharsUTF8BehaviourTest) [test/multibyte_chars_test.rb:241]: 12 expected but was 13.
-
Jeremy Kemper August 10th, 2009 @ 03:37 AM
- State changed from open to incomplete
Applied to master (prematurely): 4dda9b644df5e4386f693a4b7bd00fe787f41a28
Need to be compat with 1.9 before 2-3-stable backport.
-
Elad Meidar August 10th, 2009 @ 03:58 AM
- Assigned user cleared.
i was having a problem with the functionality using RTL languages as values, since rindex always scans left to right, strings were truncated in the wrong way.
-
Jeremy Kemper August 10th, 2009 @ 04:19 AM
- Assigned user set to Jeremy Kemper
-
Erik Ostrom August 10th, 2009 @ 04:54 AM
- Assigned user cleared.
Ruby 1.9 helpfully points out that my test is wrong - which means my implementation is, too. Developing...
-
Erik Ostrom August 10th, 2009 @ 07:19 AM
I've attached a patch to be applied after my earlier one. The test is fixed so it passes on Ruby 1.9, and the implementation is fixed so it passes the fixed test. The offset parameter wasn't being translated into bytes before calling the underlying string method.
index had an equivalent bug, which went unnoticed because the test cases all used the default offset, and a 0-character offset translates to 0 bytes. I added some offset tests and fixed the bug in #index.
I also threw in a couple of negative-offset tests, inspired by #2428, of which this ticket is a duplicate. (Andy Stewart's patch from that one no longer applies cleanly to master, but I wish I'd noticed it earlier.)
These tests passed (for me) on Ruby 1.9.2 Preview 1 and Ruby 1.8.6.
-
Repository August 10th, 2009 @ 07:33 AM
- State changed from incomplete to committed
(from [7d16e94d827197d030fdd611db4310396aeb0114]) Correctly handle offsets in Multibyte::Chars#index and #rindex.
The offset in codepoints was being passed directly to the wrapped string's index/rindex method. Now we translate the offset into bytes first.
[#3028 state:committed]
Signed-off-by: Jeremy Kemper jeremy@bitsweat.net
http://github.com/rails/rails/commit/7d16e94d827197d030fdd611db4310... -
Repository August 10th, 2009 @ 07:33 AM
(from [4e014379a3c792281138c5a19a5bd74e9435fede]) Correctly handle offsets in Multibyte::Chars#index and #rindex.
The offset in codepoints was being passed directly to the wrapped string's index/rindex method. Now we translate the offset into bytes first.
[#3028 state:committed]
Signed-off-by: Jeremy Kemper jeremy@bitsweat.net
http://github.com/rails/rails/commit/4e014379a3c792281138c5a19a5bd7... -
Jeremy Kemper August 10th, 2009 @ 07:34 AM
- Tag changed from 2, 2.3.x, 3, 3.0, bugmash, multibyte to 2, 2.3.x, 3, 3.0, multibyte
-
Rizwan Reza January 20th, 2010 @ 11:54 AM
- State changed from committed to resolved
-
Andrea Campi October 16th, 2010 @ 11:44 PM
- Tag changed from 2, 2.3.x, 3, 3.0, multibyte to 2-3-stable, 2.3.x, 3, 3.0, multibyte
- Importance changed from to
Create your profile
Help contribute to this project by taking a few moments to create your personal profile. Create your profile »
<h2 style="font-size: 14px">Tickets have moved to Github</h2>
The new ticket tracker is available at <a href="https://github.com/rails/rails/issues">https://github.com/rails/rails/issues</a>
People watching this ticket
Attachments
Tags
Referenced by
- 2428 Unicode-aware rindex method #3028. Unfortunately this ticket was overlooked before pu...
- 3028 ActiveSupport::Multibyte::Chars [#3028 state:committed]
- 3028 ActiveSupport::Multibyte::Chars [#3028 state:committed]