Fix #48403 broken UNC paths in markdown images#74332
Conversation
|
I just added another commit. The previous one was just handling UNC paths. With project in the root of a drive, this code: if (!startsWith(normalizedPath.fsPath, root.fsPath + sep)) {When So, as it always concatenates the
Resulting in a |
|
Thanks for looking into this. Marking for June since it is too late to merge for the May release. @lmcarreiro Can you please quickly overview how you tested that this change works and that it does not cause regressions? |
|
@mjbvz I know that it works because I created a shared folder in my PC with the example of a simple I ran the automated tests with and without my changes and the results were the same. About the possibility of regressions, I don't think that would be any, because of the kind of these changes:
Anyway, I don't know the architecture of this project. The only resource I found about this was the Code-Organization that doesn't help too much. If there is anything that could be made in a better way, or if it would be better to be fixed in other place of the code, just give me directions and I'll try to do it. |
|
Hey can you please take a quick look at resolving the merge conflicts for this PR. The webview code has been reworked quite a bit recently to support the web. I intended to merge this PR earlier but it fell off my radar |
|
I saw that the code I changed was moved into the new file resourceLoader.ts. So, I moved my changes to this file, it worked for paths at the root of a network mapped drive, but it didn't for an UNC path. It is missing a slash after the contents.session.protocol.registerBufferProtocol(protocol, (request, callback: any) => {
// request.uri for UNC paths:
// It used to be like: "vscode-resource://desktop-9su47m5/test-vscode-issue/350x150.png"
// Now it is like: "vscode-resource:/desktop-9su47m5/test-vscode-issue/350x150.png"I did a |
|
I added a comment there in the line that introduced the change: https://github.com/microsoft/vscode/pull/75741/files#r296498579 -<base href="${markdownDocument.uri.with({ scheme: 'vscode-resource' }).toString(true)}">
+<base href="${toResoruceUri(markdownDocument.uri)}">
-<!--<base href="vscode-resource://desktop-9su47m5/test-vscode-issue/test.md">-->
+<!--<base href="vscode-resource:/test-vscode-issue/test.md">-->Anyway, I rewrote my changes in the new file resourceLoader.ts, but to work with UNC paths, you need to review this change. As you used this new method |
|
Thanks. Will fix the markdown case as part of #76489 |
Fix #48403.
It's my first PR in this repo, I don't know if it could be fixed in a better way, if so, please tell me.
The problem is:
normalizedPath.fsPathwon't have the//desktop-9su47m5part of the path, becausenormalizedPathvariable is constructed withURI.file("/test-vscode-issue/350x150.png"), so the condition!startsWith(normalizedPath.fsPath, root.fsPath + sep)will never be false with UNC paths.