Fix ß bug in regexp for mentions and tags (#31122)
parent
e881a59671
commit
337a7fcf30
|
@ -68,7 +68,7 @@ class Account < ApplicationRecord
|
|||
INSTANCE_ACTOR_ID = -99
|
||||
|
||||
USERNAME_RE = /[a-z0-9_]+([a-z0-9_.-]+[a-z0-9_]+)?/i
|
||||
MENTION_RE = %r{(?<![=/[:word:]])@((#{USERNAME_RE})(?:@[[:word:].-]+[[:word:]]+)?)}i
|
||||
MENTION_RE = %r{(?<![=/[:word:]])@((#{USERNAME_RE})(?:@[[:word:].-]+[[:word:]]+)?)}
|
||||
URL_PREFIX_RE = %r{\Ahttp(s?)://[^/]+}
|
||||
USERNAME_ONLY_RE = /\A#{USERNAME_RE}\z/i
|
||||
USERNAME_LENGTH_LIMIT = 30
|
||||
|
|
|
@ -37,7 +37,7 @@ class Tag < ApplicationRecord
|
|||
HASHTAG_LAST_SEQUENCE = '([[:word:]_]*[[:alpha:]][[:word:]_]*)'
|
||||
HASHTAG_NAME_PAT = "#{HASHTAG_FIRST_SEQUENCE}|#{HASHTAG_LAST_SEQUENCE}"
|
||||
|
||||
HASHTAG_RE = %r{(?<![=/)\p{Alnum}])#(#{HASHTAG_NAME_PAT})}i
|
||||
HASHTAG_RE = %r{(?<![=/)\p{Alnum}])#(#{HASHTAG_NAME_PAT})}
|
||||
HASHTAG_NAME_RE = /\A(#{HASHTAG_NAME_PAT})\z/i
|
||||
HASHTAG_INVALID_CHARS_RE = /[^[:alnum:]\u0E47-\u0E4E#{HASHTAG_SEPARATORS}]/
|
||||
|
||||
|
|
|
@ -711,6 +711,14 @@ RSpec.describe Account do
|
|||
it 'does not match URL query string' do
|
||||
expect(subject.match('https://example.com/?x=@alice')).to be_nil
|
||||
end
|
||||
|
||||
it 'matches usernames immediately following the letter ß' do
|
||||
expect(subject.match('Hello toß @alice from me')[1]).to eq 'alice'
|
||||
end
|
||||
|
||||
it 'matches usernames containing uppercase characters' do
|
||||
expect(subject.match('Hello to @aLice@Example.com from me')[1]).to eq 'aLice@Example.com'
|
||||
end
|
||||
end
|
||||
|
||||
describe 'validations' do
|
||||
|
|
|
@ -95,6 +95,14 @@ RSpec.describe Tag do
|
|||
it 'does not match purely-numeric hashtags' do
|
||||
expect(subject.match('hello #0123456')).to be_nil
|
||||
end
|
||||
|
||||
it 'matches hashtags immediately following the letter ß' do
|
||||
expect(subject.match('Hello toß #ruby').to_s).to eq '#ruby'
|
||||
end
|
||||
|
||||
it 'matches hashtags containing uppercase characters' do
|
||||
expect(subject.match('Hello #rubyOnRails').to_s).to eq '#rubyOnRails'
|
||||
end
|
||||
end
|
||||
|
||||
describe '#to_param' do
|
||||
|
|
Loading…
Reference in New Issue