Skip to content
This repository has been archived by the owner on Apr 30, 2021. It is now read-only.

Commit

Permalink
Merge pull request #72 from yurigorokhov/iri_testing
Browse files Browse the repository at this point in the history
Add XUri(XUri) Constructor
  • Loading branch information
Arne Claassen committed Oct 23, 2012
2 parents 7fd682d + ae1b91b commit e4e42ba
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/mindtouch.dream/dream/XUri.cs
Expand Up @@ -976,6 +976,12 @@ public sealed class XUri : ISerializable {
/// <param name="uri">Input uri.</param>
public XUri(Uri uri) : this(uri.OriginalString) { }

/// <summary>
/// Create a new XUri from an existing XUri
/// </summary>
/// <param name="uri">Input uri.</param>
public XUri(XUri uri) : this(uri.Scheme, uri.User, uri.Password, uri.Host, uri.Port, uri.UsesDefaultPort, uri.Segments, uri.TrailingSlash, uri.Params, uri.Fragment, uri.UsesSegmentDoubleEncoding) { }

/// <summary>
/// Create a new XUri from serialized form.
/// </summary>
Expand Down
17 changes: 17 additions & 0 deletions src/tests/DreamMisc/XUri-Test.cs
Expand Up @@ -531,6 +531,23 @@ public class XUriTest {
}
}

[Test]
public void TestXUriFromUriConstruction2() {
string[] evilSegments = new string[] {

// Escaped version of "Iñtërnâtiônàlizætiøn" (should look similar to "Internationalization" but with extended characteres)
"I\u00f1t\u00ebrn\u00e2ti\u00f4n\u00e0liz\u00e6ti\u00f8n",
"A%4b"
};
foreach(string evil in evilSegments) {
XUri original = new XUri("http://" + evil);
XUri fromDecoded = new XUri(original.ToString());
XUri uri1 = new XUri(original);
XUri uri2 = new XUri(fromDecoded);
// just making sure they actually parse
}
}

[Test]
public void Decode_extended_chars1() {
const string before = "F\u00F4\u00F6";
Expand Down

0 comments on commit e4e42ba

Please sign in to comment.