Correctly escape chars in email addresses

Without this, some email address with strange chars were not removable
master
Daniel Berteaud 11 years ago
parent bd0535c940
commit 652682b00a
  1. 11
      public/js/vroom.js

@ -81,8 +81,8 @@ function inviteUrlPopup(){
// Add a new email address to be notified whn someone joins
function addNotifiedEmail(email){
var id = email.replace('@', '_AT_').replace('.', '_DOT_');
$('<li></li>').html(email + ' <a href="javascript:void(0);" onclick="removeNotifiedEmail(\'' + email + '\');" title="' + locale.REMOVE_THIS_ADDRESS + '">' +
var id = email.replace(/['"]/g, '_');
$('<li></li>').html(email + ' <a href="javascript:void(0);" onclick="removeNotifiedEmail(\'' + email.replace('\'', '\\\'') + '\');" title="' + locale.REMOVE_THIS_ADDRESS + '">' +
' <span class="glyphicon glyphicon-remove-circle"></span>' +
' </a>')
.attr('id', 'emailNotification_' + id)
@ -91,7 +91,7 @@ function addNotifiedEmail(email){
// Remove the address from the list
function removeNotifiedEmail(email){
var id = email.replace('@', '_AT_').replace('.', '_DOT_');
var id = escapeJqSelector(email.replace(/['"]/, '_').replace('\\\'', '\''));
$.ajax({
data: {
action: 'emailNotification',
@ -115,6 +115,11 @@ function removeNotifiedEmail(email){
});
}
// Taken from http://totaldev.com/content/escaping-characters-get-valid-jquery-id
function escapeJqSelector(string){
return string.replace(/([;&,\.\+\*\~':"\!\^#$%@\[\]\(\)=>\|])/g, '\\$1');
}
// Escape entities
function stringEscape(string){
string = string.replace(/[\u00A0-\u99999<>\&]/gim, function(i) {

Loading…
Cancel
Save