Repository navigation
Conversation
…ultProps (LAZ-1698)
|
This PR has conflicts. You need to rebase the PR before it can be merged. |
|
This PR doesn't have conflicts anymore. It can be merged after all status checks have passed and it has been reviewed. |
|
This PR has conflicts. You need to rebase the PR before it can be merged. |
|
This PR doesn't have conflicts anymore. It can be merged after all status checks have passed and it has been reviewed. |
…p v6 extensions rendering (LAZ-1698)
…gins on their own (LAZ-1698)
r1chm8
left a comment
There was a problem hiding this comment.
Thanks for working through all of these. I'm treating this as the last round: the two comments below are the only blockers, and I'll approve once they're in without doing another full review. Anything else I spot from here goes into a follow-up ticket rather than this PR.
| if (["http:", "https:", "data:"].includes(url.protocol)) { | ||
| return src; | ||
| } | ||
| return url.protocol === "file:" && url.host === "" ? src : undefined; |
There was a problem hiding this comment.
This still lets network-share images through in one form. file:////host/share/x.png and the relative ////host/share/x.png both parse with host === "" and pathname //host/share/x.png, so they pass this check and the original src goes through unchanged. Chromium on Windows reads file:////server/share as the UNC path \\server\share, so the image would still open an SMB connection, which is the case this is meant to block.
Could we also drop anything whose pathname starts with // (and the backslash forms)? Please add both forms to the tests, and check them on Windows if you can, since I haven't been able to confirm the UNC behaviour there.
| if (url === null || url === undefined) { | ||
| return undefined; | ||
| } | ||
| return key === "src" ? imageSrc(url) : (webHref(url) ?? mailHref(url)); |
There was a problem hiding this comment.
An extension's own components.a or components.img can now get href or src as undefined. Under 6 these were always strings, so a custom a that does href.startsWith("http") or new URL(href) now throws on [see below](#section), a relative link or steam:, and the extension's UI unmounts.
Could custom components get "" instead (keeping undefined for WebLink), or, if we'd rather keep undefined, add it to the react-markdown section of MIGRATION.md and the CHANGELOG entry? It isn't in either at the moment.
https://linear.app/nexus-mods/issue/LAZ-1698/clear-the-react-deprecation-warnings-out-of-the-renderer-tests
Summary
Upgrades react-markdown from 6 to 9, so it stops logging a React deprecation warning (
defaultProps) in our tests. Markdown looks the same to users, apart from the link and image changes below.util/react_markdown/ReactMarkdown.tsx) loads it, and everything imports it from there. A lint rule stops direct imports.WebLinkby default.defaultPropswarning, from function or memo components, so it can't come back.Evidence
defaultProps.After: 38 warnings, no
defaultProps. All tests pass.steam:, relative,//share,tel:linksdata:image and//shareimagedata:shows; network-share image has nosrchttp://fsf.org/is plain text, not a linkrequire("react-markdown")withlinkTarget,transformImageUriWhy 9, not 10: 9.1.0 still supports
className, which v10 removes, so the sixclassName=call sites keep working unchanged.What changes for links and images
steam:,nxm:,file:) do nothing when clicked, as in 6. Without the fix, 9 gave themhref="", which reloads the whole window.../run.exe,//server/share/run.exe) no longer open. Before, they resolved against the app'sfile://page and opened through the shell. This affects extension dialogs,More, LOOT messages and the bundled issue-tracker and changelog dashlet.tel:links no longer open. Links only keep http(s) andmailto:targets, even with a caller's ownaorurlTransform.[x](url "Title")) no longer show as hover text.disallowedElementsnamedlinkbefore, which matches nothing.//host/…,file://host/…), which no longer load.Extension authors
require("react-markdown")from an extension now gets a Vortex-provided component that is also its own.default, and carries 9's other exports and 6'suriTransformer. Every way of importing 6 still works:require,import ReactMarkdown from,import * asandimport =. Its links and images are filtered as above.transformLinkUriandtransformImageUristill run, throughurlTransform. The other props 9 dropped, including the ones 6 had already deprecated (renderers,source,plugins, …), are ignored. All of them are logged as deprecated API use. Remark or rehype plugins made for 6 that throw under 9 are dropped and reported, so the markdown still renders.This is in
packages/vortex-api/CHANGELOG.md, and in a new react-markdown section inpackages/vortex-api/docs/MIGRATION.md.Merge Danger
Door: two-way. Reverting brings back the old version and its warning.
Blast Radius: markdown. Anywhere Vortex or an extension shows markdown (dialogs, About page, collection instructions, plugin list, extension UIs) uses the new version.