Skip to content

Commit

Permalink
fix(decode): Fix off-by-one error (#858)
Browse files Browse the repository at this point in the history
  • Loading branch information
fb55 committed Jul 1, 2022
1 parent b349edf commit 3b0d48b
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
3 changes: 3 additions & 0 deletions src/decode.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,4 +39,7 @@ describe("Decode test", () => {

it("should not parse numeric entities in strict mode", () =>
expect(entities.decodeHTMLStrict("&#55")).toBe("&#55"));

it("should parse &nbsp followed by < (#852)", () =>
expect(entities.decodeHTML("&nbsp<")).toBe("\u00a0<"));
});
2 changes: 1 addition & 1 deletion src/decode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ export function determineBranch(
if (jumpOffset) {
const value = char - jumpOffset;

return value < 0 || value > branchCount
return value < 0 || value >= branchCount
? -1
: decodeTree[nodeIdx + value] - 1;
}
Expand Down

0 comments on commit 3b0d48b

Please sign in to comment.