Repository navigation
fix(images): fetch image paths with parentheses - #2
Merged
Merged
Conversation
`.png)` stopped reading the path at the first `)`, so the extension tried to fetch `a(b`, failed, and stopped the export over an image that exists. The destination now accepts balanced and backslash-escaped parentheses and escaped angle brackets, and keeps the old first-`)` reading for an unbalanced `(`. Backslash escapes are undone for markdown images only.
Review found regressions in the new destination pattern: - `` became a path, because `\.` accepted whitespace. - `.png>)` lost its backslash, a path separator on Windows. Inside angle brackets only `\<` and `\>` are escapes now. - `` stopped matching. Unescaped `<` is allowed again. Also handles a second level of nested parentheses, and unrolls the angle branch, which overflowed the stack above about 8 million characters.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
MAK-355. Same bug as makesPDF/makespdf-obsidian-plugin#17, in a different pattern.
Bug
.png)stopped reading the path at the first), so the extension tried to fetcha(b, failed, and stopped the export over an image that exists..png)and.png)failed the same way, reproduced againstmain.Change
MD_IMAGEaccepts parentheses balanced to two levels and backslash-escaped parentheses, and keeps the first-)reading for an unbalanced(, which already worked.cleanMarkdownSrcundoes\(,\),\<and\>in bare destinations, and only\<and\>inside angle brackets, where a backslash before a parenthesis is a Windows path separator (<pics\(1).png>). HTMLsrcvalues have no such escapes and stay oncleanSrc.Verification
npm test: 102 passed, 8 of them new, including unterminated destinations and a 16 MB data URI in both bare and angle form.npm run typecheck,npm run buildandnpm run verify:packagespass. Timings match the old pattern on the repeated and unterminated inputs measured up to 80,000 characters.An independent review agent ran on the first commit; its findings are fixed in the second, which has not had a separate review. The reviewer ran the URL logic of
src/adapters/github.tsundernew URLfor these paths with correct results, but with no real fetch.Not checked
A real GitHub fetch of such a path, or a run in a browser.
Known limits
). Use angle brackets for those.(see )or "t")now reads the path asu(v.png), which matches the server's parser. The old pattern readu(v.png.(a)or\(can overflow the regex stack. It is far over the 5 MB image limit and the export reports a misleading fetch error.