52 lines
2.2 KiB
C#
52 lines
2.2 KiB
C#
|
// Decompiled with JetBrains decompiler
|
|||
|
// Type: Rei.Fs.NoHostRootedUriParser
|
|||
|
// Assembly: Rei.Fs, Version=1.13.2.8796, Culture=neutral, PublicKeyToken=null
|
|||
|
// MVID: D8B08A8B-697C-4439-9CFF-1BE4EE46F7B0
|
|||
|
// Assembly location: F:\Eigene Dateien\Dropbox\portable Collection\Progs\CarotDAV\Rei.Fs.dll
|
|||
|
|
|||
|
using Microsoft.VisualBasic.CompilerServices;
|
|||
|
using System;
|
|||
|
using System.Reflection;
|
|||
|
using System.Security.Permissions;
|
|||
|
|
|||
|
namespace Rei.Fs
|
|||
|
{
|
|||
|
public class NoHostRootedUriParser : GenericUriParser
|
|||
|
{
|
|||
|
private static readonly GenericUriParserOptions ParserOptions = GenericUriParserOptions.DontUnescapePathDotsAndSlashes | GenericUriParserOptions.Idn | GenericUriParserOptions.IriParsing;
|
|||
|
private const int MustHaveAuthority = 1;
|
|||
|
private const int OptionalAuthority = 2;
|
|||
|
|
|||
|
public static void Register(string scheme, int defaultport)
|
|||
|
{
|
|||
|
if (UriParser.IsKnownScheme(scheme))
|
|||
|
return;
|
|||
|
UriParser.Register((UriParser) new NoHostRootedUriParser(), scheme, defaultport);
|
|||
|
}
|
|||
|
|
|||
|
public NoHostRootedUriParser()
|
|||
|
: base(NoHostRootedUriParser.ParserOptions)
|
|||
|
{
|
|||
|
ReflectionPermission reflectionPermission = new ReflectionPermission(ReflectionPermissionFlag.AllFlags);
|
|||
|
SecurityPermission securityPermission = new SecurityPermission(SecurityPermissionFlag.AllFlags);
|
|||
|
reflectionPermission.Demand();
|
|||
|
securityPermission.Demand();
|
|||
|
FieldInfo field = typeof (UriParser).GetField("m_Flags", BindingFlags.Instance | BindingFlags.NonPublic);
|
|||
|
int num = Conversions.ToInteger(field.GetValue((object) this)) & -2 | 2;
|
|||
|
field.SetValue((object) this, (object) num);
|
|||
|
}
|
|||
|
|
|||
|
protected override void InitializeAndValidate(Uri uri, ref UriFormatException parsingError)
|
|||
|
{
|
|||
|
base.InitializeAndValidate(uri, out parsingError);
|
|||
|
if (parsingError == null && Operators.CompareString(uri.Host, "", false) != 0)
|
|||
|
parsingError = new UriFormatException("should not contain host");
|
|||
|
if (parsingError == null && !uri.AbsolutePath.StartsWith("/"))
|
|||
|
parsingError = new UriFormatException("should be absolute path");
|
|||
|
if (parsingError != null || uri.Port > 0)
|
|||
|
return;
|
|||
|
parsingError = new UriFormatException("should not contain port");
|
|||
|
}
|
|||
|
}
|
|||
|
}
|