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

File URI cannot be parsed with @ sign #24002

Closed
twsouthwick opened this issue Oct 30, 2017 · 7 comments
Closed

File URI cannot be parsed with @ sign #24002

twsouthwick opened this issue Oct 30, 2017 · 7 comments

Comments

@twsouthwick
Copy link
Member

The DocumentFormat.OpenXml library uses System.IO.Packaging to open office related documents. A user posted an issue where one of the package relationships uses a legacy URI format that fails to be parsed. This document opens fine in PowerPoint and would like to be able to open it with the .NET library. The URI in question has the form:

file:///\\contoso.com@SSL\user\content\path\projects\blank.xlsx
@davidsh
Copy link
Contributor

davidsh commented Oct 30, 2017

Does this work .NET Framework?

@twsouthwick
Copy link
Member Author

No. This fails to parse on both .NET Framework and .NET Core.

@twsouthwick
Copy link
Member Author

Here's a repro:

using System;

namespace ConsoleApp6
{
    class Program
    {
        static void Main(string[] args)
        {
            try
            {
                var result = new Uri(@"file:///\\contoso.com@SSL\user\content\path\projects\blank.xlsx", UriKind.Absolute);
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
            }
        }
    }
}

And the error:

System.UriFormatException: Invalid URI: The hostname could not be parsed.
   at System.Uri.CreateThis(String uri, Boolean dontEscape, UriKind uriKind)
   at ConsoleApp6.Program.Main(String[] args) in C:\Users\tasou\source\repos\ConsoleApp6\ConsoleApp6\Program.cs:line 11

@davidsh
Copy link
Contributor

davidsh commented Oct 31, 2017

where one of the package relationships uses a legacy URI format that fails to be parsed

Can you point to the relevant RFC for URI's that describe this "legacy" format? Since both .NET Framework and .NET Core don't support this format, we need to understand more about it. Most of the URI RFC's we support are in RFC 3986, 3987 (IRIs).

@poizan42
Copy link
Contributor

That looks more like a UNC path naively prefixed with "file:///" than any sort of valid URI. Maybe OpenXML should do its own parsing if it need to support that?

@twsouthwick
Copy link
Member Author

@poizan42 may be right. Looks like this is a WebDAV path expressed as a UNC path (see https://en.wikipedia.org/wiki/Path_(computing)) with file:/// prepended. Office seems to be able to handle it, but I can't find any documentation for what the format is.

@twsouthwick
Copy link
Member Author

Since this seems to be a non-standard way of forming a URI, I'll close this for now. Thanks for the help!

@msftgits msftgits transferred this issue from dotnet/corefx Jan 31, 2020
@msftgits msftgits added this to the 2.1.0 milestone Jan 31, 2020
@ghost ghost locked as resolved and limited conversation to collaborators Dec 19, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

4 participants