diff options
author | Mark Longair <mhl@pobox.com> | 2013-10-04 17:29:21 +0100 |
---|---|---|
committer | Mark Longair <mhl@pobox.com> | 2013-10-04 17:29:21 +0100 |
commit | 6a857d9a42629da7c430ddf6c865cb7eb73a8901 (patch) | |
tree | 7cefba76990385b8acb51594cbff1baccd2e739a /app/models | |
parent | abfbb63875850922052da6e0626bdba4e137af65 (diff) |
Fix upcasing of a non-US-ASCII first letter under Ruby 1.8
In the rare circumstance that someone created a public body
whose name started with a lower case letter outside [a-z]
with Alaveteli running under Ruby 1.8, the letter would not be
upcased correctly before saving to the first_letter column.
This commit fixes that by using a Unicode-aware upcase function.
Diffstat (limited to 'app/models')
-rw-r--r-- | app/models/public_body.rb | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/app/models/public_body.rb b/app/models/public_body.rb index 828e8c94a..485a794b0 100644 --- a/app/models/public_body.rb +++ b/app/models/public_body.rb @@ -71,7 +71,7 @@ class PublicBody < ActiveRecord::Base def PublicBody.set_first_letter(instance) unless instance.name.nil? or instance.name.empty? # we use a regex to ensure it works with utf-8/multi-byte - first_letter = instance.name.scan(/^./mu)[0].upcase + first_letter = Unicode.upcase instance.name.scan(/^./mu)[0] if first_letter != instance.first_letter instance.first_letter = first_letter end |