Skip to content

non-linear back tracking in the regex used in getDataProtocolModuleFormat #33

@JLHwung

Description

@JLHwung

const {1: mime} = /^([^/]+\/[^;,]+)[^,]*?(;base64)?,/.exec(
parsed.pathname
) || [null, null, null]

The ESLint rule regexp/no-super-linear-backtracking reports that

The quantifier '[^;,]+' can exchange characters with '[^,]*?'. Using any string accepted by /[^,;]+/, this can be exploited to cause at least polynomial backtracking.

For example, if the pathname is ./aaaaaaaaaaaB, the back tracking becomes polynomial since both [^;,]+ and [^,]*? match a.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions