diff options
| author | paolo-delmundo | 2013-10-02 20:49:20 +0100 | 
|---|---|---|
| committer | Pete Bacon Darwin | 2013-10-03 08:42:15 +0100 | 
| commit | e66c23fe55f8571a014b0686c8dbca128e7a8240 (patch) | |
| tree | 6d0eae30b0180fb3999c9ec022728c63b56eabfa /src/ngSanitize | |
| parent | e36e28ebd4a6c144e47d11fba8e211d8d5a9d03e (diff) | |
| download | angular.js-e66c23fe55f8571a014b0686c8dbca128e7a8240.tar.bz2 | |
fix($sanitize): sanitize DOCTYPE declarations correctly
HTML to be sanitized that contains a DOCTYPE declaration were causing
the HTML parser to throw an error.  Now the parser correctly removes
the declarations when sanitizing HTML.
Closes #3931
Diffstat (limited to 'src/ngSanitize')
| -rw-r--r-- | src/ngSanitize/sanitize.js | 8 | 
1 files changed, 8 insertions, 0 deletions
diff --git a/src/ngSanitize/sanitize.js b/src/ngSanitize/sanitize.js index ffee51df..1d03dd9d 100644 --- a/src/ngSanitize/sanitize.js +++ b/src/ngSanitize/sanitize.js @@ -135,6 +135,7 @@ var START_TAG_REGEXP = /^<\s*([\w:-]+)((?:\s+[\w:-]+(?:\s*=\s*(?:(?:"[^"]*")|(?:    BEGIN_TAG_REGEXP = /^</,    BEGING_END_TAGE_REGEXP = /^<\s*\//,    COMMENT_REGEXP = /<!--(.*?)-->/g, +  DOCTYPE_REGEXP = /<!DOCTYPE([^>]*?)>/i,    CDATA_REGEXP = /<!\[CDATA\[(.*?)]]>/g,    URI_REGEXP = /^((ftp|https?):\/\/|mailto:|tel:|#)/i,    NON_ALPHANUMERIC_REGEXP = /([^\#-~| |!])/g; // Match everything outside of normal chars and " (quote character) @@ -218,7 +219,14 @@ function htmlParser( html, handler ) {            html = html.substring( index + 3 );            chars = false;          } +      // DOCTYPE +      } else if ( DOCTYPE_REGEXP.test(html) ) { +        match = html.match( DOCTYPE_REGEXP ); +        if ( match ) { +          html = html.replace( match[0] , ''); +          chars = false; +        }        // end tag        } else if ( BEGING_END_TAGE_REGEXP.test(html) ) {          match = html.match( END_TAG_REGEXP );  | 
