Skip to content

Commit

Permalink
fix(sanitize-html): use explicit metadata
Browse files Browse the repository at this point in the history
  • Loading branch information
EisenbergEffect committed Mar 14, 2015
1 parent bd5c890 commit 8aa3a13
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
1 change: 1 addition & 0 deletions README.md
Expand Up @@ -13,6 +13,7 @@ This library is part of the [Aurelia](http://www.aurelia.io/) platform and conta
* [aurelia-templating](https://github.com/aurelia/templating)
* [aurelia-dependency-injection](https://github.com/aurelia/dependency-injection)
* [aurelia-binding](https://github.com/aurelia/binding)
* [aurelia-logging](https://github.com/aurelia/logging)

## Used By

Expand Down
10 changes: 9 additions & 1 deletion src/sanitize-html.js
@@ -1,6 +1,12 @@
import {Behavior} from 'aurelia-templating';

var SCRIPT_REGEX = /<script\b[^<]*(?:(?!<\/script>)<[^<]*)*<\/script>/gi;

export class SanitizeHtmlValueConverter {
static metadata(){
return Behavior.valueConverter('sanitize-html');
}

static defaultSanitizer(untrustedMarkup){
return untrustedMarkup.replace(SCRIPT_REGEX, '');
}
Expand All @@ -10,8 +16,10 @@ export class SanitizeHtmlValueConverter {
}

toView(untrustedMarkup){
if (untrustedMarkup === null)
if(untrustedMarkup === null){
return null;
}

return this.sanitizer(untrustedMarkup);
}
}

0 comments on commit 8aa3a13

Please sign in to comment.