LINQ XElement.load method not working correctly with strings withperiods in them

M

Mike N.

hello all:

I am using LINQ to XML, but I think this issue is more widespread,
here's an example of what I am trying to do:

Dim testurl As String = "http://stats.enemyterritory.com/profile/
Hellfire.?xml=true"
Dim pageContents As XElement = XElement.Load(testurl)

The url in question is for a game statistics site where you can load
xml data for various players, in this case the player name has a
period
in it at the end, it's "hellfire." (another similar is "Red.")

If you take that url and plug it into a browser everything is fine,
but when I use it in the XElement Load method it drops the period, in
the case where there is a similar name without a period it returns
that page (which is the wrong one), in the case where there is no
similar name without a period it doesn't return anything.

I escaped with "%2e" and that doesn't help. Everything is fine if
there is a period in the middle of the string, it's only the one's at
the end which are an issue.

Any ideas on how to get this to work?

Thanks in advance to any who offer help.

Mike
 
J

Jeroen Mostert

Mike said:
hello all:

I am using LINQ to XML, but I think this issue is more widespread,
here's an example of what I am trying to do:

Dim testurl As String = "http://stats.enemyterritory.com/profile/
Hellfire.?xml=true"
Dim pageContents As XElement = XElement.Load(testurl)

The url in question is for a game statistics site where you can load
xml data for various players, in this case the player name has a
period
in it at the end, it's "hellfire." (another similar is "Red.")

If you take that url and plug it into a browser everything is fine,
but when I use it in the XElement Load method it drops the period, in
the case where there is a similar name without a period it returns
that page (which is the wrong one), in the case where there is no
similar name without a period it doesn't return anything.

I escaped with "%2e" and that doesn't help. Everything is fine if
there is a period in the middle of the string, it's only the one's at
the end which are an issue.
This is a bug in the way .NET parses URIs. It removes the dot at the end
(possibly to work around an infamous IIS bug) but this is not legal
according to the standard, which says: "parsers must remove the dot-segments
"." and ".." when they are complete components of a path, but not when they
are only part of a segment" and gives an example of a path ending in a dot.

This is not specific to LINQ; any code path which uses the Uri class will
trigger this problem.
Any ideas on how to get this to work?
Right now, I don't.
 
M

Mike N.

This is a bug in the way .NET parses URIs. It removes the dot at the end
(possibly to work around an infamous IIS bug) but this is not legal
according to the standard, which says: "parsers must remove the dot-segments
"." and ".." when they are complete components of a path, but not when they
are only part of a segment" and gives an example of a path ending in a dot.

This is not specific to LINQ; any code path which uses the Uri class will
trigger this problem.


Right now, I don't.

That sucks, this is a pretty big deal for my app. I guess maybe I
could try and run an outside dll or something like that, maybe
something written in PHP or Perl (although I wouldn't even no where to
start with something like that).

Thanks for replying and enlightening me.

If anyone has some advice I'd really appreciate any help on this.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top