Skip to content
This repository has been archived by the owner on Jul 15, 2019. It is now read-only.

Commit

Permalink
minor speed optimization
Browse files Browse the repository at this point in the history
  • Loading branch information
adon committed Mar 30, 2015
1 parent a13e0c3 commit 697b50c
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/xss-filters.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ exports._getPrivFilters = function () {
NULL = /\x00/g,
SPECIAL_ATTR_VALUE_UNQUOTED_CHARS = /(?:^(?:["'`]|\x00+$|$)|[\x09-\x0D >])/g,
SPECIAL_HTML_CHARS = /[&<>"'`]/g,
SPECIAL_COMMENT_CHARS = /(?:^-*!?>|--!?>|--?!?$|\]>|\]$)/g;
SPECIAL_COMMENT_CHARS = /(?:\x00|^-*!?>|--!?>|--?!?$|\]>|\]$)/g;

// Given a full URI, need to support "[" ( IPv6address ) "]" in URI as per RFC3986
// Reference: https://tools.ietf.org/html/rfc3986
Expand Down Expand Up @@ -105,9 +105,9 @@ exports._getPrivFilters = function () {
return typeof s === STR_UD ? STR_UD
: s === null ? STR_NL
: s.toString()
.replace(NULL, '\uFFFD')
.replace(SPECIAL_COMMENT_CHARS, function(m){
return m === '--!' || m === '--' || m === '-' || m === ']' ? m + ' '
return m === '\x00' ? '\uFFFD'
: m === '--!' || m === '--' || m === '-' || m === ']' ? m + ' '
:/*
: m === ']>' ? '] >'
: m === '-->' ? '-- >'
Expand Down

0 comments on commit 697b50c

Please sign in to comment.