Chinese Character supported

pull/1130/head
pauking 10 years ago
parent 7586600fe1
commit a2b3bf472a
  1. 2
      packages/rocketchat-lib/server/functions/setUsername.coffee
  2. 2
      packages/rocketchat-lib/server/methods/setUsername.coffee
  3. 4
      packages/rocketchat-mentions/client.coffee
  4. 4
      packages/rocketchat-mentions/server.coffee
  5. 2
      server/methods/createChannel.coffee
  6. 2
      server/methods/createPrivateGroup.coffee
  7. 2
      server/methods/saveRoomName.coffee
  8. 4
      server/restapi/restapi.coffee

@ -3,7 +3,7 @@ RocketChat.setUsername = (user, username) ->
if not user or not username
return false
if not /^[0-9a-zA-Z-_.\u00C0-\u017F]+$/.test username
if not /^[0-9a-zA-Z-_.\u00C0-\u017F\u4e00-\u9fa5]+$/.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-_.\u00C0-\u017F]+$/.test username
if not /^[0-9a-zA-Z-_.\u00C0-\u017F\u4e00-\u9fa5]+$/.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

@ -10,7 +10,7 @@ class MentionsClient
mentions = []
message.msg.replace /(?:^|\s|\n)(?:@)([0-9a-zA-Z-_.\u00C0-\u017F]+)/g, (match, mention) ->
message.msg.replace /(?:^|\s|\n)(?:@)([0-9a-zA-Z-_.\u00C0-\u017F\u4e00-\u9fa5]+)/g, (match, mention) ->
mentions.push mention
me = Meteor.user()?.username
@ -33,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-_.\u00C0-\u017F]+)/g, (match, mention) ->
message.msg.replace /(?:^|\s|\n)(?:#)([A-Za-z0-9-_.\u00C0-\u017F\u4e00-\u9fa5]+)/g, (match, mention) ->
channels.push mention
if channels.length isnt 0

@ -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-_.\u00C0-\u017F]+)/g, (match, mention) ->
message.msg.replace /(?:^|\s|\n)(?:@)([A-Za-z0-9-_.\u00C0-\u017F\u4e00-\u9fa5]+)/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-_.\u00C0-\u017F]+)/g, (match, mention) ->
message.msg.replace /(?:^|\s|\n)(?:#)([A-Za-z0-9-_.\u00C0-\u017F\u4e00-\u9fa5]+)/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-zA-Z-_\u00C0-\u017F]+$/.test name
if not /^[0-9a-zA-Z-_\u00C0-\u017F\u4e00-\u9fa5]+$/.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-zA-Z-_\u00C0-\u017F]+$/.test name
if not /^[0-9a-zA-Z-_\u00C0-\u017F\u4e00-\u9fa5]+$/.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-zA-Z-_\u00C0-\u017F]+$/.test name
if not /^[0-9a-zA-Z-_\u00C0-\u017F\u4e00-\u9fa5]+$/.test name
throw new Meteor.Error 'name-invalid'
name = _.slugify name

@ -61,7 +61,7 @@ Api.testapiValidateUsers = (users) ->
if user.name?
if user.email?
if user.pass?
if /^[0-9a-zA-Z-_\u00C0-\u017F]+$/i.test user.name
if /^[0-9a-zA-Z-_\u00C0-\u017F\u4e00-\u9fa5]+$/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-zA-Z-_\u00C0-\u017F]+$/i.test room.name
if /^[0-9a-zA-Z-_\u00C0-\u017F\u4e00-\u9fa5]+$/i.test room.name
continue
throw new Meteor.Error 'invalid-room-record', "[restapi] bulk/createRoom -> record #" + i + " is invalid"
return

Loading…
Cancel
Save