-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix downcasing of unicode tag names #492
Conversation
Tests are failing. |
My mistake. do I need to repush this commits as one? |
Since you will need to push the changelog , rebase and push as one. |
This is related to #464 as well |
Would you mind modifying the change-log as well ? |
Fix downcasing of unicode tag names
Thank you |
Sqlite3 tests are failing. :/ |
I'll check this |
How can I reproduce those testing errors in my local code? |
Maybe rolling back |
Do you want to send a PR ? |
else | ||
string.to_s.mb_chars | ||
string.to_s |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@leo-souza is returning a string, should not be returning a ActiveSupport::Multibyte::Chars
?
Maybe this broke the build.
Suggestion:
def as_8bit_ascii(string, downcase=false)
string = string.to_s
string.downcase! if downcase
if defined?(Encoding)
string.dup.force_encoding('BINARY')
else
string.mb_chars
end
end
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
#mb_chars
have to be called before #downcase
or else Á would not become á. But either way, I don't think the else
block is being called at all. But this is a good suggestion, maybe just removing #to_s
is a good try. If only the tests fail locally
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The mb_chars code was legacy 1.8 that I left in there. That's why it's in the elsif Encoding is not defined.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ruby downcase method doesn't apply to multibyte chars unless you call mb_chars before downcase, even for 1.9+
Yes, I do. |
I noticed that. If you restart the tests , they often pass. |
@@ -111,11 +111,13 @@ def binary | |||
/mysql/ === ActiveRecord::Base.connection_config[:adapter] ? "BINARY " : nil | |||
end | |||
|
|||
def as_8bit_ascii(string) | |||
def as_8bit_ascii(string, downcase=false) | |||
string = string.to_s.dup.mb_chars |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why use mb_chars here? Unnecessary in Ruby 1.9
Fix downcasing of unicode tag names
I ran into some issues when a tag name contains upcased unicode chars.
It happens in both creation and retrieving:
tagged_with
is called, it returns an empty array, even when calling with the exact tag name.Examples:
This behaviour was introduced when
.force_encoding('BINARY')
was added inTag
class, which was being called before downcasing the stringWhen sqlite is being used, the only way around this is loading the ICU extension.
PR #472 only fixes the tagged_with part of this issue.