Skip to content

Commit

Permalink
Fix : encodeURIComponent() does not handle -_.!~*'() characters well
Browse files Browse the repository at this point in the history
  • Loading branch information
HoldOffHunger committed Jan 14, 2019
1 parent 1651ab2 commit aa006b8
Showing 1 changed file with 22 additions and 16 deletions.
38 changes: 22 additions & 16 deletions code/javascript/javascript/social-share-media.js
Original file line number Diff line number Diff line change
Expand Up @@ -124,22 +124,22 @@ function GetSocialMediaSiteLinks_WithShareLinks(args) {
}
}

const url = encodeURIComponent(args.url);
const title = encodeURIComponent(args.title);
const image = encodeURIComponent(args.image);
const desc = encodeURIComponent(args.desc);
const app_id = encodeURIComponent(args.appid);
const redirect_url = encodeURIComponent(args.redirecturl);
const via = encodeURIComponent(args.via);
const hash_tags = encodeURIComponent(args.hashtags);
const provider = encodeURIComponent(args.provider);
const language = encodeURIComponent(args.language);
const user_id = encodeURIComponent(args.userid);
const category = encodeURIComponent(args.category);
const phone_number = encodeURIComponent(args.phonenumber);
const email_address = encodeURIComponent(args.emailaddress);
const cc_email_address = encodeURIComponent(args.ccemailaddress);
const bcc_email_address = encodeURIComponent(args.bccemailaddress);
const url = fixedEncodeURIComponent(args.url);
const title = fixedEncodeURIComponent(args.title);
const image = fixedEncodeURIComponent(args.image);
const desc = fixedEncodeURIComponent(args.desc);
const app_id = fixedEncodeURIComponent(args.appid);
const redirect_url = fixedEncodeURIComponent(args.redirecturl);
const via = fixedEncodeURIComponent(args.via);
const hash_tags = fixedEncodeURIComponent(args.hashtags);
const provider = fixedEncodeURIComponent(args.provider);
const language = fixedEncodeURIComponent(args.language);
const user_id = fixedEncodeURIComponent(args.userid);
const category = fixedEncodeURIComponent(args.category);
const phone_number = fixedEncodeURIComponent(args.phonenumber);
const email_address = fixedEncodeURIComponent(args.emailaddress);
const cc_email_address = fixedEncodeURIComponent(args.ccemailaddress);
const bcc_email_address = fixedEncodeURIComponent(args.bccemailaddress);

var text = title;

Expand Down Expand Up @@ -186,3 +186,9 @@ function GetSocialMediaSiteLinks_WithShareLinks(args) {
'yahoo':'http://compose.mail.yahoo.com/?to=' + email_address + '&subject=' + title + '&body=' + text,
};
}

function fixedEncodeURIComponent(str) {
return encodeURIComponent(str).replace(/[!'()*]/g, function(c) {
return '%' + c.charCodeAt(0).toString(16);
});
}

0 comments on commit aa006b8

Please sign in to comment.