diff --git a/app/assets/javascripts/discourse/dialects/category_hashtag_dialect.js b/app/assets/javascripts/discourse/dialects/category_hashtag_dialect.js index 1ea3052b8eb..4beb7ab537e 100644 --- a/app/assets/javascripts/discourse/dialects/category_hashtag_dialect.js +++ b/app/assets/javascripts/discourse/dialects/category_hashtag_dialect.js @@ -4,7 +4,7 @@ **/ Discourse.Dialect.inlineRegexp({ start: '#', - matcher: /^#([\w-]{1,50})/, + matcher: /^#([\w-]{1,50})/i, spaceOrTagBoundary: true, emitter: function(matches) { diff --git a/app/assets/javascripts/discourse/dialects/mention_dialect.js b/app/assets/javascripts/discourse/dialects/mention_dialect.js index 1641c309439..3848ae1503b 100644 --- a/app/assets/javascripts/discourse/dialects/mention_dialect.js +++ b/app/assets/javascripts/discourse/dialects/mention_dialect.js @@ -7,11 +7,11 @@ Discourse.Dialect.inlineRegexp({ start: '@', // NOTE: since we can't use SiteSettings here (they loads later in process) // we are being less strict to account for more cases than allowed - matcher: /^@([\w.-]+)/, + matcher: /^@(\w[\w.-]{0,59})\b/i, wordBoundary: true, emitter: function(matches) { - var mention = matches[0], + var mention = matches[0].trim(), name = matches[1], mentionLookup = this.dialect.options.mentionLookup; diff --git a/app/models/username_validator.rb b/app/models/username_validator.rb index 891958b169b..e0ba6cfacb7 100644 --- a/app/models/username_validator.rb +++ b/app/models/username_validator.rb @@ -61,21 +61,21 @@ class UsernameValidator def username_char_valid? return unless errors.empty? - if username =~ /[^A-Za-z0-9_\.\-]/ + if username =~ /[^\w.-]/ self.errors << I18n.t(:'user.username.characters') end end def username_first_char_valid? return unless errors.empty? - if username[0] =~ /[^A-Za-z0-9_]/ + if username[0] =~ /[^\w]/ self.errors << I18n.t(:'user.username.must_begin_with_alphanumeric') end end def username_last_char_valid? return unless errors.empty? - if username[-1] =~ /[^A-Za-z0-9_]/ + if username[-1] =~ /[^\w]/ self.errors << I18n.t(:'user.username.must_end_with_alphanumeric') end end