Skip to content
This repository was archived by the owner on Apr 12, 2024. It is now read-only.
This repository was archived by the owner on Apr 12, 2024. It is now read-only.

NON_ALPHANUMERIC_REGEXP in ngSanitize #3192

Closed
@JasonCust

Description

@JasonCust

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:

  1. Why are escaped formatting characters like newline (\n), tab (\t), etc. included in this?
  2. 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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions