Skip to content

fix(document): auto-detect declared/BOM charset instead of forcing UTF-8 - #3108

Merged
abose merged 2 commits into
mainfrom
ai
Aug 17, 2026
Merged

fix(document): auto-detect declared/BOM charset instead of forcing UTF-8#3108
abose merged 2 commits into
mainfrom
ai

fix(document): fix encoding cache poisoning and skip redundant re-det…

7ff2e16
Select commit
Loading
Failed to load commit list.
SonarQubeCloud / SonarCloud Code Analysis succeeded Aug 17, 2026 in 43s

Annotations

Check warning on line 138 in src/document/EncodingDetector.js

See this annotation in the file changed.

@sonarqubecloud sonarqubecloud / SonarCloud Code Analysis

Expected a `for-of` loop instead of a `for` loop with this simple iteration.

See more on https://sonarcloud.io/project/issues?id=phcode-dev_phoenix&issues=AaAOHZjuzCBAWVJo1HUR&open=AaAOHZjuzCBAWVJo1HUR&pullRequest=3108

Check warning on line 96 in src/document/EncodingDetector.js

See this annotation in the file changed.

@sonarqubecloud sonarqubecloud / SonarCloud Code Analysis

Move function '_normalizeEncodingName' to the outer scope.

See more on https://sonarcloud.io/project/issues?id=phcode-dev_phoenix&issues=AaAOHZjuzCBAWVJo1HUQ&open=AaAOHZjuzCBAWVJo1HUQ&pullRequest=3108

Check warning on line 154 in src/document/EncodingDetector.js

See this annotation in the file changed.

@sonarqubecloud sonarqubecloud / SonarCloud Code Analysis

Handle this exception or don't catch it at all.

See more on https://sonarcloud.io/project/issues?id=phcode-dev_phoenix&issues=AaAOHZjuzCBAWVJo1HUU&open=AaAOHZjuzCBAWVJo1HUU&pullRequest=3108

Check warning on line 73 in src/document/EncodingDetector.js

See this annotation in the file changed.

@sonarqubecloud sonarqubecloud / SonarCloud Code Analysis

Simplify this regular expression to reduce its runtime, as it has super-linear performance due to backtracking.

See more on https://sonarcloud.io/project/issues?id=phcode-dev_phoenix&issues=AaAOHZjuzCBAWVJo1HUO&open=AaAOHZjuzCBAWVJo1HUO&pullRequest=3108

Check warning on line 137 in src/document/EncodingDetector.js

See this annotation in the file changed.

@sonarqubecloud sonarqubecloud / SonarCloud Code Analysis

Prefer `String.fromCodePoint()` over `String.fromCharCode()`.

See more on https://sonarcloud.io/project/issues?id=phcode-dev_phoenix&issues=AaAOHZjuzCBAWVJo1HUS&open=AaAOHZjuzCBAWVJo1HUS&pullRequest=3108

Check warning on line 202 in src/document/EncodingDetector.js

See this annotation in the file changed.

@sonarqubecloud sonarqubecloud / SonarCloud Code Analysis

Prefer using an optional chain expression instead, as it's more concise and easier to read.

See more on https://sonarcloud.io/project/issues?id=phcode-dev_phoenix&issues=AaAOHZjuzCBAWVJo1HUX&open=AaAOHZjuzCBAWVJo1HUX&pullRequest=3108

Check warning on line 73 in src/document/EncodingDetector.js

See this annotation in the file changed.

@sonarqubecloud sonarqubecloud / SonarCloud Code Analysis

Remove duplicates in this character class.

See more on https://sonarcloud.io/project/issues?id=phcode-dev_phoenix&issues=AaAOHZjuzCBAWVJo1HUP&open=AaAOHZjuzCBAWVJo1HUP&pullRequest=3108

Check warning on line 168 in src/document/EncodingDetector.js

See this annotation in the file changed.

@sonarqubecloud sonarqubecloud / SonarCloud Code Analysis

Prefer using an optional chain expression instead, as it's more concise and easier to read.

See more on https://sonarcloud.io/project/issues?id=phcode-dev_phoenix&issues=AaAOHZjuzCBAWVJo1HUV&open=AaAOHZjuzCBAWVJo1HUV&pullRequest=3108

Check warning on line 202 in src/document/EncodingDetector.js

See this annotation in the file changed.

@sonarqubecloud sonarqubecloud / SonarCloud Code Analysis

Use `.includes()`, rather than `.indexOf()`, when checking for existence.

See more on https://sonarcloud.io/project/issues?id=phcode-dev_phoenix&issues=AaAOHZjuzCBAWVJo1HUY&open=AaAOHZjuzCBAWVJo1HUY&pullRequest=3108

Check warning on line 148 in src/document/EncodingDetector.js

See this annotation in the file changed.

@sonarqubecloud sonarqubecloud / SonarCloud Code Analysis

Move function '_isValidUTF8' to the outer scope.

See more on https://sonarcloud.io/project/issues?id=phcode-dev_phoenix&issues=AaAOHZjuzCBAWVJo1HUT&open=AaAOHZjuzCBAWVJo1HUT&pullRequest=3108

Check warning on line 260 in src/document/EncodingDetector.js

See this annotation in the file changed.

@sonarqubecloud sonarqubecloud / SonarCloud Code Analysis

Move function 'isKnownTextEncoding' to the outer scope.

See more on https://sonarcloud.io/project/issues?id=phcode-dev_phoenix&issues=AaAOLANwKbB-PIbWk5Wa&open=AaAOLANwKbB-PIbWk5Wa&pullRequest=3108

Check warning on line 179 in src/document/EncodingDetector.js

See this annotation in the file changed.

@sonarqubecloud sonarqubecloud / SonarCloud Code Analysis

Use `.includes()`, rather than `.indexOf()`, when checking for existence.

See more on https://sonarcloud.io/project/issues?id=phcode-dev_phoenix&issues=AaAOHZjuzCBAWVJo1HUW&open=AaAOHZjuzCBAWVJo1HUW&pullRequest=3108