Skip to content

Instantly share code, notes, and snippets.

@binki
Last active September 25, 2018 13:53
Show Gist options
  • Save binki/e87ddf1aa5d46883047926376b0ae00a to your computer and use it in GitHub Desktop.
Save binki/e87ddf1aa5d46883047926376b0ae00a to your computer and use it in GitHub Desktop.
Excerpt of Glip weird “do not send scripts” JavaScript
EC_Model.prototype.validate_string=function(a,b,c) {
if(!_.isNull(a)) {
if(_.isString(a)) {
if(a.length>b) {
return Errors.Too_Long(b);
}
if(a.match(/<script/gi)) {
return Errors.No_Script();
} }else {
return Errors.Invalid_Type();
}
if(a=a.match(/<.*?>/g)) {
for(b=0; b<a.length; b++) {
if(c=a[b],c.match(/\s+on\w/g) || c.match(/=\s?["|']?javascript/g)) {
return Errors.No_Script();
}
}
}
}
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment