Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Problem/Bug]: WebView2 When opening a local PDF file, if the file path contains #, the PDF file fails to be opened. #4777

Open
lh0328 opened this issue Aug 29, 2024 · 1 comment
Assignees
Labels
bug Something isn't working

Comments

@lh0328
Copy link

lh0328 commented Aug 29, 2024

What happened?

If I set the D:\Work\Report\TPL\NKK#7555\PDFViewer1.pdf path when I call WebView2's Navigate method, the PDF file fails to open because the folder name in the path contains a "#".

Importance

Important. My app's user experience is significantly compromised.

Runtime Channel

Stable release (WebView2 Runtime)

Runtime Version

121.0.2277.128

SDK Version

1.0.2210.55

Framework

Win32

Operating System

Windows 10

OS Version

19045.4651

Repro steps

Set the local path to "D:\Work\Report\TPL\ nkk# 7555\ pdfviewer.pdf" and prefix it with "file://".
Calling the Navigate method of WebView2 failed to open the PDF.

After some debugging, WebView2's Navigate method splits the path according to '#", If the "D:\Work\Report\TPL\NKK" path exists, the "NKK" file or folder is opened, but if the path does not exist, an error is reported that the file was not found

Repros in Edge Browser

Yes, issue can be reproduced in the corresponding Edge version

Regression

Don't know

Last working version (if regression)

No response

@lh0328 lh0328 added the bug Something isn't working label Aug 29, 2024
@monica-ch
Copy link
Contributor

@lh0328 Looks like # character in the file path is being interpreted as a fragment identifier by the WebView2 Navigate method. To resolve this, you can encode the # character in the file path.

Try this
file://D:/Work/Report/TPL/nkk%237555/pdfviewer.pdf

Try using this encoded path with the Navigate method in WebView2. This should prevent the method from splitting the path incorrectly. Let me know if this works for you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants
@lh0328 @monica-ch and others