NON_ALPHANUMERIC_REGEXP in ngSanitize #3192
Description
Within the ngSanitize module, the stated purpose of the regex NON_ALPHANUMERIC_REGEXP is 'Match everything outside of normal chars and " (quote character)', which it appears to do.
However I have two questions regarding this:
- Why are escaped formatting characters like newline (\n), tab (\t), etc. included in this?
- Why is a capture used in the regex when it's never used? Also, couldn't it be simplified from:
/([^\#-~| |!])/g
to:/[^ -~]/g
I think the simplified character class reads a bit more clear. Also, it appears the intended use of the pipes in the original character class are for an 'or' which is not necessary as character classes by definition match character by character. In this case they are simply just a pipe character. Escaping the pound symbol is also not necessary.
If it was just an oversight on the escaped formatting characters mentioned above, the simplified regex could then be updated to: /[^\n\t -~]/g
.
I apologize if I have glossed over something in the source.