diff --git a/app/assets/javascripts/discourse/components/user-selector.js.es6 b/app/assets/javascripts/discourse/components/user-selector.js.es6 index 19c12841b5c..15d50faedae 100644 --- a/app/assets/javascripts/discourse/components/user-selector.js.es6 +++ b/app/assets/javascripts/discourse/components/user-selector.js.es6 @@ -25,6 +25,7 @@ export default TextField.extend({ allowAny: this.get('allowAny'), dataSource: function(term) { + term = term.replace(/[^a-zA-Z0-9_]/, ''); return userSearch({ term: term, topicId: self.get('topicId'), diff --git a/config/locales/server.en.yml b/config/locales/server.en.yml index 6f80709df49..75ac418fb90 100644 --- a/config/locales/server.en.yml +++ b/config/locales/server.en.yml @@ -231,8 +231,8 @@ en: base: warning_requires_pm: "You can only attach warnings to private messages." too_many_users: "You can only send warnings to one user at a time." - archetype: cant_send_pm: "Sorry, you cannot send a private message to that user." + no_user_selected: "You must select a valid user." user: attributes: password: diff --git a/lib/topic_creator.rb b/lib/topic_creator.rb index 42b7d94e1a1..035af608872 100644 --- a/lib/topic_creator.rb +++ b/lib/topic_creator.rb @@ -114,7 +114,7 @@ class TopicCreator @topic.subtype = TopicSubtype.user_to_user unless @topic.subtype unless @opts[:target_usernames].present? || @opts[:target_group_names].present? - @topic.errors.add(:archetype, :cant_send_pm) + @topic.errors.add(:base, :no_user_selected) @errors = @topic.errors raise ActiveRecord::Rollback.new end @@ -150,7 +150,7 @@ class TopicCreator def check_can_send_permission!(topic,item) unless @guardian.can_send_private_message?(item) - topic.errors.add(:archetype, :cant_send_pm) + topic.errors.add(:base, :cant_send_pm) @errors = topic.errors raise ActiveRecord::Rollback.new end