Commit e8073cb
authored
fix(rust): prevent panic in doc link parsing (#2879)
This commit fixes a panic in the `isLinkDestination` function that
occurred when a URL was located at the very end of a line. The function
was attempting to access the character after the URL without checking
bounds, leading to an index out of range error.
The fix involves:
1. Checking if the URL is preceded by `](` to confirm it is part of a
link destination.
2. Safely handling the case where the URL is at the end of the line
(inferring a closing parenthesis).
3. Checking for the closing `)` only if the index is within bounds.
This ensures that truncated links or bare URLs at the end of lines are
handled gracefully without crashing the generator.1 parent c20a5f3 commit e8073cb
2 files changed
+14
-2
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1020 | 1020 | | |
1021 | 1021 | | |
1022 | 1022 | | |
1023 | | - | |
| 1023 | + | |
| 1024 | + | |
| 1025 | + | |
| 1026 | + | |
| 1027 | + | |
| 1028 | + | |
| 1029 | + | |
| 1030 | + | |
| 1031 | + | |
1024 | 1032 | | |
1025 | 1033 | | |
1026 | 1034 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1756 | 1756 | | |
1757 | 1757 | | |
1758 | 1758 | | |
1759 | | - | |
| 1759 | + | |
| 1760 | + | |
| 1761 | + | |
1760 | 1762 | | |
1761 | 1763 | | |
1762 | 1764 | | |
| |||
1773 | 1775 | | |
1774 | 1776 | | |
1775 | 1777 | | |
| 1778 | + | |
| 1779 | + | |
1776 | 1780 | | |
1777 | 1781 | | |
1778 | 1782 | | |
| |||
0 commit comments