Skip to content
Snippets Groups Projects
Commit 1cf330cb authored by Marcelo Schmidt's avatar Marcelo Schmidt
Browse files

Enable international characters

parent 1875e331
No related branches found
No related tags found
No related merge requests found
......@@ -3,7 +3,7 @@ RocketChat.setUsername = (user, username) ->
if not user or not username
return false
if not /^[0-9a-zA-Z-_.]+$/.test username
if not /^[0-9a-zA-Z-_.\u00C0-\u017F]+$/.test username
return false
# User already has desired username, return
......
......@@ -10,7 +10,7 @@ Meteor.methods
if user.username is username
return username
if not /^[0-9a-zA-Z-_.]+$/.test username
if not /^[0-9a-zA-Z-_.\u00C0-\u017F]+$/.test username
throw new Meteor.Error 'username-invalid', "#{username} is not a valid username, use only letters, numbers, dots and dashes"
if not RocketChat.checkUsernameAvailability username
......
......@@ -9,7 +9,8 @@ class MentionsClient
msg = message.html
mentions = []
message.msg.replace /(?:^|\s|\n)(?:@)([A-Za-z0-9-_.]+)/g, (match, mention) ->
message.msg.replace /(?:^|\s|\n)(?:@)([0-9a-zA-Z-_.\u00C0-\u017F]+)/g, (match, mention) ->
mentions.push mention
me = Meteor.user()?.username
......@@ -32,7 +33,7 @@ class MentionsClient
return match.replace mention, "<a href=\"\" class=\"#{classes}\" data-username=\"#{username}\">#{mention}</a>"
channels = []
message.msg.replace /(?:^|\s|\n)(?:#)([A-Za-z0-9-_.]+)/g, (match, mention) ->
message.msg.replace /(?:^|\s|\n)(?:#)([A-Za-z0-9-_.\u00C0-\u017F]+)/g, (match, mention) ->
channels.push mention
if channels.length isnt 0
......@@ -48,4 +49,4 @@ class MentionsClient
message.html = msg
return message
RocketChat.callbacks.add 'renderMessage', MentionsClient
\ No newline at end of file
RocketChat.callbacks.add 'renderMessage', MentionsClient
......@@ -7,7 +7,7 @@ class MentionsServer
constructor: (message) ->
# If message starts with /me, replace it for text formatting
mentions = []
message.msg.replace /(?:^|\s|\n)(?:@)([A-Za-z0-9-_.]+)/g, (match, mention) ->
message.msg.replace /(?:^|\s|\n)(?:@)([A-Za-z0-9-_.\u00C0-\u017F]+)/g, (match, mention) ->
mentions.push mention
if mentions.length isnt 0
mentions = _.unique mentions
......@@ -25,7 +25,7 @@ class MentionsServer
message.mentions = verifiedMentions
channels = []
message.msg.replace /(?:^|\s|\n)(?:#)([A-Za-z0-9-_.]+)/g, (match, mention) ->
message.msg.replace /(?:^|\s|\n)(?:#)([A-Za-z0-9-_.\u00C0-\u017F]+)/g, (match, mention) ->
channels.push mention
if channels.length isnt 0
......
......@@ -3,7 +3,7 @@ Meteor.methods
if not Meteor.userId()
throw new Meteor.Error 'invalid-user', "[methods] createChannel -> Invalid user"
if not /^[0-9a-z-_]+$/.test name
if not /^[0-9a-zA-Z-_\u00C0-\u017F]+$/.test name
throw new Meteor.Error 'name-invalid'
if RocketChat.authz.hasPermission(Meteor.userId(), 'create-c') isnt true
......
......@@ -8,7 +8,7 @@ Meteor.methods
console.log '[methods] createPrivateGroup -> '.green, 'userId:', Meteor.userId(), 'arguments:', arguments
if not /^[0-9a-z-_]+$/.test name
if not /^[0-9a-zA-Z-_\u00C0-\u017F]+$/.test name
throw new Meteor.Error 'name-invalid'
now = new Date()
......
......@@ -12,7 +12,7 @@ Meteor.methods
#if room.u._id isnt Meteor.userId() and not hasPermission
throw new Meteor.Error 403, 'Not allowed'
if not /^[0-9a-z-_]+$/.test name
if not /^[0-9a-zA-Z-_\u00C0-\u017F]+$/.test name
throw new Meteor.Error 'name-invalid'
name = _.slugify name
......
......@@ -14,7 +14,7 @@ Meteor.methods
{image, contentType} = RocketChatFile.dataURIParse dataURI
rs = RocketChatFile.bufferToStream new Buffer(image, 'base64')
ws = RocketChatFileAvatarInstance.createWriteStream "#{user.username}.jpg", contentType
ws = RocketChatFileAvatarInstance.createWriteStream encodeURIComponent("#{user.username}.jpg"), contentType
ws.on 'end', Meteor.bindEnvironment ->
Meteor.setTimeout ->
RocketChat.models.Users.setAvatarOrigin user._id, service
......
......@@ -61,7 +61,7 @@ Api.testapiValidateUsers = (users) ->
if user.name?
if user.email?
if user.pass?
if /^[0-9a-z-_]+$/i.test user.name
if /^[0-9a-zA-Z-_\u00C0-\u017F]+$/i.test user.name
if /\b[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]+\b/i.test user.email
continue
throw new Meteor.Error 'invalid-user-record', "[restapi] bulk/register -> record #" + i + " is invalid"
......@@ -125,7 +125,7 @@ Api.testapiValidateRooms = (rooms) ->
if room.name?
if room.members?
if room.members.length > 1
if /^[0-9a-z-_]+$/i.test room.name
if /^[0-9a-zA-Z-_\u00C0-\u017F]+$/i.test room.name
continue
throw new Meteor.Error 'invalid-room-record', "[restapi] bulk/createRoom -> record #" + i + " is invalid"
return
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment