Skip to content

Commit

Permalink
fix typst-parser: array index overflow in parseGroupsOfArguments()
Browse files Browse the repository at this point in the history
  • Loading branch information
qwinsi committed Jan 23, 2025
1 parent 1e46310 commit b84c433
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
1 change: 1 addition & 0 deletions src/typst-parser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -457,6 +457,7 @@ export class TypstParser {
// start: the position of the left parentheses
parseGroupsOfArguments(tokens: TypstToken[], start: number): [TypstNode[][], TypstNamedParams, number] {
const end = find_closing_match(tokens, start);
tokens = tokens.slice(0, end);

const matrix: TypstNode[][] = [];
let named_params: TypstNamedParams = {};
Expand Down
11 changes: 10 additions & 1 deletion test/integration-cases.yml
Original file line number Diff line number Diff line change
Expand Up @@ -405,4 +405,13 @@ cases:
typst: a_(23)
- title: number in superscript
tex: a^{23}
typst: a^(23)
typst: a^(23)
- title: matrixes
tex: |-
\left[\begin{matrix}
a_x & a_1 \\ a_1 & a_x
\end{matrix} \right] + \left[\begin{matrix}
a_y & a_2 \\ a_2 & a_y
\end{matrix} \right]
typst: |-
mat(delim: "[", a_x , a_1 ; a_1 , a_x) + mat(delim: "[", a_y, a_2; a_2, a_y)

0 comments on commit b84c433

Please sign in to comment.