uli-weltersbach / XPathTools

A Visual Studio Extension which can run any XPath and XPath function; navigates through results at the click of a button. Can show and copy any XPath incl. XML namespaces, avoiding XML namespace induced headaches. Keeps track of the current XPath via the statusbar.
41 stars 4 forks source link

Timeout while loading external DTD #30

Closed Relax594 closed 5 years ago

Relax594 commented 5 years ago

XmlRepository.TryParseXml is getting a timeout while loading this external DTD from my given xml.

We are using a Proxy in our company, maybe that is causing the issue but idk

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

uli-weltersbach commented 5 years ago

Hi Dominik,

I'm looking into the issue, which doesn't seem to be caused by your proxy. Note to self: https://msdn.microsoft.com/en-us/library/aa302284.aspx

uli-weltersbach commented 5 years ago

Hi @Relax594

The issue should be resolved in v5.2.1. Please let me know if it works out for you.

Relax594 commented 5 years ago

Hi @uli-weltersbach

That did not fix it as i get a System.IO.DirectoryNotFoundException now. Looks like he is trying to search that DTD on my local pc

C:/Users/dotel/Desktop/-//W3C//DTD XHTML 1.0 Strict//EN

now.

This accures in FileXmlUrlResolver.GetEntity. Looks like the absoluteUri is set to search local however

uli-weltersbach commented 5 years ago

@Relax594 Could you please provide a screenshot and steps to reproduce, incl. your debug settings (e.g. which exceptions to break on - "Just my code" for instance)?

uli-weltersbach commented 5 years ago

The exception is part of the XmlUrlResolver control flow BTW. Exceptions for control flow are bad - but I can't change the .NET Framework ;)

Relax594 commented 5 years ago

I've uploaded a txt file, you need to change the file extension to .xml. After that open that file in Visual Studio and try to run your plugin. test.txt

This is the exception i'm getting (it's german but i think you get the point :)). exception

Maybe there has to be a different thinking about it then because i think having a external linked DTD to a w3.org DTD is nothing special, is it?

uli-weltersbach commented 5 years ago

I can't reproduce the behavior your describing: https://www.screencast.com/t/WjOnu3HqRAu

Could you please provide your debug settings, particularly the "Just my code" setting?

image

image

uli-weltersbach commented 5 years ago

I'll restate my previous comment:

The exception is part of the XmlUrlResolver control flow. The XmlReader needs the XmlUrlResolver to throw an exception.

https://stackoverflow.com/questions/2558021/an-error-has-occurred-opening-extern-dtd-w3-org-xhtml1-transitional-dtd-503

Relax594 commented 5 years ago

My Debug Settings are like yours.

I'm using some of your classes inside my own plugin but the core should be the same and make no difference. I'm not even into getting the XPATH, it happens while loading the XML on TextViewCreated

unbenannt

unbenannt2

unbenannt3

and then we end up back again in GetEntity with the exception.

absoluteUri is file:///C:/Users/dotel/Desktop/-//W3C//DTD XHTML 1.0 Strict//EN which causes the issue

As this throws a DirectoryNotFound Exception it gets called a second time with TryParseXml(xml, baseUri, DtdProcessing.Ignore) and this is throwing

System.NotSupportedException: "URI scheme "http" isn't supported by FileXmlUrlResolver."

Getting the XPATH is working fine after that issues! It just occures that issue while loading the xml initialy at TextViewCreated

uli-weltersbach commented 5 years ago

You want me to help your debug your own VS Extension, which uses some of the code from the XML Tools extension?

Relax594 commented 5 years ago

I linked your classes inside my extension, so it uses all your methods and workflow. So there is basicly no difference.

I attach the same events and the workflow when a xml-file gets opened is the same as your extension does.

uli-weltersbach commented 5 years ago

If you run into the exception during debugging, you can ignore it because the exception is expected and required by the .NET Framework XML classes (I'm stating this for the 3rd time now).

What happens when you click "Continue" in the debugger and try to use your extension?

I'm not sure I can assist you further, without getting my hands on your extension.

Relax594 commented 5 years ago

(I'm stating this for the 3rd time now).

Then I missunderstood you, sorry for that.

As i said, its working fine if i click continue^^ It is just that loading exception i got, but if that is expected and required than i totaly missunderstood you and i'm sorry for taking your time!

uli-weltersbach commented 5 years ago

Sorry if I was unclear about it, happy I could help.