-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
Invalid hyperlink throws exception - Invalid URI: The hostname could not be parsed. #851
Comments
Can you show me the call stack? |
Just the following code can trigger the problem. string path = "Some problem Excel files"; Exception stack: |
Can you upload the file? I'd like to look into the file. Something wrong with the package relationship uri. |
This is where the exception comes from. Line 141 in b5b21c5
|
I cannot reproduce the issue with the latest NPOI code. Which NPOI version are you using? |
The latest NPOI version 2.5.6 is used. The problem comes from the behaviour changes in .NET framework.
NPOI has handled the case when For ASP.NET, even though the system is running latest .NET framework version (e.g. v4.8). If the web.config does not specify the version explicitly |
.rels xml example from your uploaded file - test.xlsx The target Uri of package looks like docProps/app.xml, xl/workbook.xml, docProps/core.xml. There is no comma in it. Are you saying Uri.ToString throws exception with these kind of relative url in .NET framework before 4.5? Or the exception is from another place related to Uri in NPOI code? If so, can you show me the call stack? |
I have created a sample ASP.NET project with NPOI 2.5.6. Please try to comment and uncomment the line For newly created ASP.NET projects, this config is added by default in web.config now, but it was not added some years ago by default. Hence, newly created project may not face this problem. I have simple fix so that the NPOI can work in all situations.
|
Ok. I can reproduce the exception. Nice discovery. Looks Uri.OriginalString is much safer than Uri.ToString() in versions before .NET framework 4.5 |
If the content of an Excel contains hyperlink, and the hyperlink is invalid such as "mailto:a@a,com", it will throw the exception "Invalid URI: The hostname could not be parsed.".
The text was updated successfully, but these errors were encountered: