kangax / kangax/html-minifier

ignoreCustomFragments do not ignore < inside regex match

Open
#1,067 4 comments 0 reactions 0 assignees View on GitHub
Dominant language
JavaScript
Stars
5k
Forks
577
PR merge metrics
No merged PRs in 30d

Description

even doing `ignoreCustomFragments: [ /\[%.*?%]/s ]`, it will not ignore `<` inside `[%` `%]`. or example:

```
[%
IF 1 < 2
-%]
BLA
[%- END %]
```

dies with:

```
[09:08:02] Error in plugin "gulp-htmlmin"
Message:
Parse Error: < 2 -%] BLA rqa14zm906f0 rqa14zm906f1 ...
```

(it must be related to the \n, because without it, it works)

```
[% IF 1 < 2 -%]
BLA
[%- END %]
```

(this works, but please pay attention at the `s` flag on the regex)

Contributor guide

No contributing guide indexed for this repository

Research direction

Reproduce the failure with the multiline [% ... %] example and the ignoreCustomFragments regex shown in the issue. Trace the ignoreCustomFragments handling and HTML parsing around the newline, then verify that the < inside the regex-matched fragment is ignored while the single-line example continues to work.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
tooling
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.