Skip to content

Commit 3b0d48b

Browse files
authored
fix(decode): Fix off-by-one error (#858)
1 parent b349edf commit 3b0d48b

File tree

2 files changed

+4
-1
lines changed

2 files changed

+4
-1
lines changed

src/decode.spec.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,4 +39,7 @@ describe("Decode test", () => {
3939

4040
it("should not parse numeric entities in strict mode", () =>
4141
expect(entities.decodeHTMLStrict("&#55")).toBe("&#55"));
42+
43+
it("should parse &nbsp followed by < (#852)", () =>
44+
expect(entities.decodeHTML("&nbsp<")).toBe("\u00a0<"));
4245
});

src/decode.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ export function determineBranch(
150150
if (jumpOffset) {
151151
const value = char - jumpOffset;
152152

153-
return value < 0 || value > branchCount
153+
return value < 0 || value >= branchCount
154154
? -1
155155
: decodeTree[nodeIdx + value] - 1;
156156
}

0 commit comments

Comments
 (0)