本文整理汇总了C#中System.UriParser类的典型用法代码示例。如果您正苦于以下问题:C# UriParser类的具体用法?C# UriParser怎么用?C# UriParser使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
UriParser类属于System命名空间,在下文中一共展示了UriParser类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: UriParser
static UriParser()
{
m_Table[HttpUri.SchemeName] = HttpUri;
HttpsUri = new BuiltInUriParser("https", 0x1bb, HttpUri.m_Flags);
m_Table[HttpsUri.SchemeName] = HttpsUri;
FtpUri = new BuiltInUriParser("ftp", 0x15, UriSyntaxFlags.AllowIriParsing | UriSyntaxFlags.AllowIdn | UriSyntaxFlags.CanonicalizeAsFilePath | UriSyntaxFlags.CompressPath | UriSyntaxFlags.ConvertPathSlashes | UriSyntaxFlags.PathIsRooted | UriSyntaxFlags.AllowAnInternetHost | UriSyntaxFlags.AllowUncHost | UriSyntaxFlags.MayHaveFragment | UriSyntaxFlags.MayHavePath | UriSyntaxFlags.MayHavePort | UriSyntaxFlags.MayHaveUserInfo | UriSyntaxFlags.MustHaveAuthority);
m_Table[FtpUri.SchemeName] = FtpUri;
FileUri = new BuiltInUriParser("file", -1, UriSyntaxFlags.AllowIriParsing | UriSyntaxFlags.AllowIdn | UriSyntaxFlags.UnEscapeDotsAndSlashes | UriSyntaxFlags.CanonicalizeAsFilePath | UriSyntaxFlags.CompressPath | UriSyntaxFlags.ConvertPathSlashes | UriSyntaxFlags.PathIsRooted | UriSyntaxFlags.AllowDOSPath | UriSyntaxFlags.FileLikeUri | UriSyntaxFlags.AllowAnInternetHost | UriSyntaxFlags.AllowUncHost | UriSyntaxFlags.AllowEmptyHost | UriSyntaxFlags.MayHaveFragment | UriSyntaxFlags.MayHavePath | UriSyntaxFlags.MustHaveAuthority);
m_Table[FileUri.SchemeName] = FileUri;
GopherUri = new BuiltInUriParser("gopher", 70, UriSyntaxFlags.AllowIriParsing | UriSyntaxFlags.AllowIdn | UriSyntaxFlags.PathIsRooted | UriSyntaxFlags.AllowAnInternetHost | UriSyntaxFlags.AllowUncHost | UriSyntaxFlags.MayHaveFragment | UriSyntaxFlags.MayHavePath | UriSyntaxFlags.MayHavePort | UriSyntaxFlags.MayHaveUserInfo | UriSyntaxFlags.MustHaveAuthority);
m_Table[GopherUri.SchemeName] = GopherUri;
NntpUri = new BuiltInUriParser("nntp", 0x77, UriSyntaxFlags.AllowIriParsing | UriSyntaxFlags.AllowIdn | UriSyntaxFlags.PathIsRooted | UriSyntaxFlags.AllowAnInternetHost | UriSyntaxFlags.AllowUncHost | UriSyntaxFlags.MayHaveFragment | UriSyntaxFlags.MayHavePath | UriSyntaxFlags.MayHavePort | UriSyntaxFlags.MayHaveUserInfo | UriSyntaxFlags.MustHaveAuthority);
m_Table[NntpUri.SchemeName] = NntpUri;
NewsUri = new BuiltInUriParser("news", -1, UriSyntaxFlags.AllowIriParsing | UriSyntaxFlags.MayHaveFragment | UriSyntaxFlags.MayHavePath);
m_Table[NewsUri.SchemeName] = NewsUri;
MailToUri = new BuiltInUriParser("mailto", 0x19, UriSyntaxFlags.AllowIriParsing | UriSyntaxFlags.AllowIdn | UriSyntaxFlags.MailToLikeUri | UriSyntaxFlags.AllowAnInternetHost | UriSyntaxFlags.AllowUncHost | UriSyntaxFlags.AllowEmptyHost | UriSyntaxFlags.MayHaveFragment | UriSyntaxFlags.MayHaveQuery | UriSyntaxFlags.MayHavePath | UriSyntaxFlags.MayHavePort | UriSyntaxFlags.MayHaveUserInfo);
m_Table[MailToUri.SchemeName] = MailToUri;
UuidUri = new BuiltInUriParser("uuid", -1, NewsUri.m_Flags);
m_Table[UuidUri.SchemeName] = UuidUri;
TelnetUri = new BuiltInUriParser("telnet", 0x17, UriSyntaxFlags.AllowIriParsing | UriSyntaxFlags.AllowIdn | UriSyntaxFlags.PathIsRooted | UriSyntaxFlags.AllowAnInternetHost | UriSyntaxFlags.AllowUncHost | UriSyntaxFlags.MayHaveFragment | UriSyntaxFlags.MayHavePath | UriSyntaxFlags.MayHavePort | UriSyntaxFlags.MayHaveUserInfo | UriSyntaxFlags.MustHaveAuthority);
m_Table[TelnetUri.SchemeName] = TelnetUri;
LdapUri = new BuiltInUriParser("ldap", 0x185, UriSyntaxFlags.AllowIriParsing | UriSyntaxFlags.AllowIdn | UriSyntaxFlags.PathIsRooted | UriSyntaxFlags.AllowAnInternetHost | UriSyntaxFlags.AllowUncHost | UriSyntaxFlags.AllowEmptyHost | UriSyntaxFlags.MayHaveFragment | UriSyntaxFlags.MayHaveQuery | UriSyntaxFlags.MayHavePath | UriSyntaxFlags.MayHavePort | UriSyntaxFlags.MayHaveUserInfo | UriSyntaxFlags.MustHaveAuthority);
m_Table[LdapUri.SchemeName] = LdapUri;
NetTcpUri = new BuiltInUriParser("net.tcp", 0x328, UriSyntaxFlags.AllowIriParsing | UriSyntaxFlags.AllowIdn | UriSyntaxFlags.UnEscapeDotsAndSlashes | UriSyntaxFlags.CanonicalizeAsFilePath | UriSyntaxFlags.CompressPath | UriSyntaxFlags.ConvertPathSlashes | UriSyntaxFlags.PathIsRooted | UriSyntaxFlags.AllowAnInternetHost | UriSyntaxFlags.MayHaveFragment | UriSyntaxFlags.MayHaveQuery | UriSyntaxFlags.MayHavePath | UriSyntaxFlags.MayHavePort | UriSyntaxFlags.MustHaveAuthority);
m_Table[NetTcpUri.SchemeName] = NetTcpUri;
NetPipeUri = new BuiltInUriParser("net.pipe", -1, UriSyntaxFlags.AllowIriParsing | UriSyntaxFlags.AllowIdn | UriSyntaxFlags.UnEscapeDotsAndSlashes | UriSyntaxFlags.CanonicalizeAsFilePath | UriSyntaxFlags.CompressPath | UriSyntaxFlags.ConvertPathSlashes | UriSyntaxFlags.PathIsRooted | UriSyntaxFlags.AllowAnInternetHost | UriSyntaxFlags.MayHaveFragment | UriSyntaxFlags.MayHaveQuery | UriSyntaxFlags.MayHavePath | UriSyntaxFlags.MustHaveAuthority);
m_Table[NetPipeUri.SchemeName] = NetPipeUri;
VsMacrosUri = new BuiltInUriParser("vsmacros", -1, UriSyntaxFlags.AllowIriParsing | UriSyntaxFlags.AllowIdn | UriSyntaxFlags.UnEscapeDotsAndSlashes | UriSyntaxFlags.CanonicalizeAsFilePath | UriSyntaxFlags.CompressPath | UriSyntaxFlags.ConvertPathSlashes | UriSyntaxFlags.AllowDOSPath | UriSyntaxFlags.FileLikeUri | UriSyntaxFlags.AllowAnInternetHost | UriSyntaxFlags.AllowUncHost | UriSyntaxFlags.AllowEmptyHost | UriSyntaxFlags.MayHaveFragment | UriSyntaxFlags.MayHavePath | UriSyntaxFlags.MustHaveAuthority);
m_Table[VsMacrosUri.SchemeName] = VsMacrosUri;
}
示例2: CheckAuthorityHelper
//
// Checks the syntax of an authority component. It may also get a userInfo if present
// Returns an error if no/mailformed authority found
// Does not NOT touch m_Info
// Returns position of the Path component
//
// Must be called in the ctor only
private unsafe ushort CheckAuthorityHelper(char* pString, ushort idx, ushort length,
ref ParsingError err, ref Flags flags, UriParser syntax, ref string newHost)
{
int end = length;
char ch;
int startInput = idx;
ushort start = idx;
newHost = null;
bool justNormalized = false;
bool iriParsing = (s_IriParsing && IriParsingStatic(syntax)); // perf
bool hasUnicode = ((flags & Flags.HasUnicode) != 0); // perf
bool hostNotUnicodeNormalized = ((flags & Flags.HostUnicodeNormalized) == 0); // perf
UriSyntaxFlags syntaxFlags = syntax.Flags;
// need to build new Iri'zed string
if (hasUnicode && iriParsing && hostNotUnicodeNormalized)
{
newHost = _originalUnicodeString.Substring(0, startInput);
}
//Special case is an empty authority
if (idx == length || ((ch = pString[idx]) == '/' || (ch == '\\' && StaticIsFile(syntax)) || ch == '#' || ch == '?'))
{
if (syntax.InFact(UriSyntaxFlags.AllowEmptyHost))
{
flags &= ~Flags.UncPath; //UNC cannot have an empty hostname
if (StaticInFact(flags, Flags.ImplicitFile))
err = ParsingError.BadHostName;
else
flags |= Flags.BasicHostType;
}
else
err = ParsingError.BadHostName;
if (hasUnicode && iriParsing && hostNotUnicodeNormalized)
{
flags |= Flags.HostUnicodeNormalized;// no host
}
return idx;
}
string userInfoString = null;
// Attempt to parse user info first
if ((syntaxFlags & UriSyntaxFlags.MayHaveUserInfo) != 0)
{
for (; start < end; ++start)
{
if (start == end - 1 || pString[start] == '?' || pString[start] == '#' || pString[start] == '\\' ||
pString[start] == '/')
{
start = idx;
break;
}
else if (pString[start] == '@')
{
flags |= Flags.HasUserInfo;
// Iri'ze userinfo
if (iriParsing || (s_IdnScope != UriIdnScope.None))
{
if (iriParsing && hasUnicode && hostNotUnicodeNormalized)
{
// Normalize user info
userInfoString = IriHelper.EscapeUnescapeIri(pString, startInput, start + 1, UriComponents.UserInfo);
newHost += userInfoString;
}
else
{
userInfoString = new string(pString, startInput, start - startInput + 1);
}
}
++start;
ch = pString[start];
break;
}
}
}
// DNS name only optimization
// Fo an overridden parsing the optimization is suppressed since hostname can be changed to anything
bool dnsNotCanonical = ((syntaxFlags & UriSyntaxFlags.SimpleUserSyntax) == 0);
if (ch == '[' && syntax.InFact(UriSyntaxFlags.AllowIPv6Host)
&& IPv6AddressHelper.IsValid(pString, (int)start + 1, ref end))
{
flags |= Flags.IPv6HostType;
_iriParsing = (s_IriParsing && IriParsingStatic(syntax));
if (hasUnicode && iriParsing && hostNotUnicodeNormalized)
{
//.........这里部分代码省略.........
示例3: UnescapeString
//
// This method will assume that any good Escaped Sequence will be unescaped in the output
// - Assumes Dest.Length - detPosition >= end-start
// - UnescapeLevel controls various modes of opearion
// - Any "bad" escape sequence will remain as is or '%' will be escaped.
// - destPosition tells the starting index in dest for placing the result.
// On return destPosition tells the last character + 1 postion in the "dest" array.
// - The control chars and chars passed in rsdvX parameters may be re-escaped depending on UnescapeLevel
// - It is a RARE case when Unescape actually needs escaping some characteres mentioned above.
// For this reason it returns a char[] that is usually the same ref as the input "dest" value.
//
internal unsafe static char[] UnescapeString(string input, int start, int end, char[] dest,
ref int destPosition, char rsvd1, char rsvd2, char rsvd3, UnescapeMode unescapeMode, UriParser syntax,
bool isQuery)
{
fixed (char *pStr = input)
{
return UnescapeString(pStr, start, end, dest, ref destPosition, rsvd1, rsvd2, rsvd3, unescapeMode,
syntax, isQuery);
}
}
示例4: Register
//
// Static Registration methods
//
//
// Registers a custom Uri parser based on a scheme string
//
public static void Register(UriParser uriParser, string schemeName, int defaultPort)
{
if (uriParser == null)
throw new ArgumentNullException("uriParser");
if (schemeName == null)
throw new ArgumentNullException("schemeName");
if (schemeName.Length == 1)
throw new ArgumentOutOfRangeException("schemeName");
if (!Uri.CheckSchemeName(schemeName))
throw new ArgumentOutOfRangeException("schemeName");
if ((defaultPort >= 0xFFFF || defaultPort < 0) && defaultPort != -1)
throw new ArgumentOutOfRangeException("defaultPort");
schemeName = schemeName.ToLower();
FetchSyntax(uriParser, schemeName, defaultPort);
}
示例5: CheckAuthorityHelperHandleDnsIri
private unsafe void CheckAuthorityHelperHandleDnsIri(char* pString, ushort start, int end, int startInput, bool iriParsing, bool hasUnicode, UriParser syntax, string userInfoString, ref Flags flags, ref bool justNormalized, ref string newHost, ref ParsingError err)
{
flags |= Flags.DnsHostType;
if ((s_IdnScope == 1) && this.IsIntranet(new string(pString, 0, end)))
{
flags |= Flags.HostNotParsed | Flags.IntranetUri;
}
if (this.AllowIdnStatic(syntax, flags))
{
bool allAscii = true;
bool atLeastOneValidIdn = false;
string idnHost = DomainNameHelper.IdnEquivalent(pString, start, end, ref allAscii, ref atLeastOneValidIdn);
string str2 = DomainNameHelper.UnicodeEquivalent(idnHost, pString, start, end);
if (!allAscii)
{
flags |= Flags.HostNotParsed | Flags.UnicodeHost;
}
if (atLeastOneValidIdn)
{
flags |= Flags.HostNotParsed | Flags.IdnHost;
}
if ((allAscii && atLeastOneValidIdn) && StaticNotAny(flags, Flags.HasUnicode))
{
this.m_originalUnicodeString = this.m_String;
newHost = this.m_originalUnicodeString.Substring(0, startInput) + (StaticInFact(flags, Flags.HasUserInfo) ? userInfoString : null);
justNormalized = true;
}
else if (!iriParsing && (StaticInFact(flags, Flags.HostNotParsed | Flags.UnicodeHost) || StaticInFact(flags, Flags.HostNotParsed | Flags.IdnHost)))
{
this.m_originalUnicodeString = this.m_String;
newHost = this.m_originalUnicodeString.Substring(0, startInput) + (StaticInFact(flags, Flags.HasUserInfo) ? userInfoString : null);
justNormalized = true;
}
if (!allAscii || atLeastOneValidIdn)
{
this.m_DnsSafeHost = idnHost;
newHost = newHost + str2;
justNormalized = true;
}
else if ((allAscii && !atLeastOneValidIdn) && (iriParsing && hasUnicode))
{
newHost = newHost + str2;
justNormalized = true;
}
}
else if (hasUnicode)
{
string str3 = StripBidiControlCharacter(pString, start, end - start);
try
{
newHost = newHost + ((str3 != null) ? str3.Normalize(NormalizationForm.FormC) : null);
}
catch (ArgumentException)
{
err = ParsingError.BadHostName;
}
justNormalized = true;
}
flags |= Flags.HostNotParsed | Flags.HostUnicodeNormalized;
}
示例6: UnescapeString
private static unsafe char[] UnescapeString(string input, int start, int end, char[] dest, ref int destPosition, char rsvd1, char rsvd2, char rsvd3, UnescapeMode unescapeMode, UriParser syntax, bool isQuery, bool readOnlyConfig)
{
fixed (char* str = ((char*) input))
{
char* pStr = str;
return UnescapeString(pStr, start, end, dest, ref destPosition, rsvd1, rsvd2, rsvd3, unescapeMode, syntax, isQuery, readOnlyConfig);
}
}
示例7: StaticIsFile
private static bool StaticIsFile(UriParser syntax)
{
return syntax.InFact(UriSyntaxFlags.FileLikeUri);
}
示例8: ParseScheme
private static unsafe ParsingError ParseScheme(string uriString, ref Flags flags, ref UriParser syntax)
{
int length = uriString.Length;
if (length == 0)
{
return ParsingError.EmptyUriString;
}
if (length >= 0xfff0)
{
return ParsingError.SizeLimit;
}
fixed (char* str = ((char*) uriString))
{
char* chPtr = str;
ParsingError none = ParsingError.None;
ushort num2 = ParseSchemeCheckImplicitFile(chPtr, (ushort) length, ref none, ref flags, ref syntax);
if (none != ParsingError.None)
{
return none;
}
flags |= (Flags) num2;
}
return ParsingError.None;
}
示例9: Uri
// Should never be used except by the below method
private Uri(Flags flags, UriParser uriParser, string uri)
{
_flags = flags;
_syntax = uriParser;
_string = uri;
}
示例10: UriParser
static UriParser()
{
s_table = new LowLevelDictionary<string, UriParser>(c_InitialTableSize);
s_tempTable = new LowLevelDictionary<string, UriParser>(c_InitialTableSize);
//Now we will call for the instance constructors that will interrupt this static one.
// Below we simulate calls into FetchSyntax() but avoid using lock() and other things redundant for a .cctor
HttpUri = new BuiltInUriParser("http", 80, HttpSyntaxFlags);
s_table[HttpUri.SchemeName] = HttpUri; //HTTP
HttpsUri = new BuiltInUriParser("https", 443, HttpUri._flags);
s_table[HttpsUri.SchemeName] = HttpsUri; //HTTPS cloned from HTTP
WsUri = new BuiltInUriParser("ws", 80, HttpSyntaxFlags);
s_table[WsUri.SchemeName] = WsUri; // WebSockets
WssUri = new BuiltInUriParser("wss", 443, HttpSyntaxFlags);
s_table[WssUri.SchemeName] = WssUri; // Secure WebSockets
FtpUri = new BuiltInUriParser("ftp", 21, FtpSyntaxFlags);
s_table[FtpUri.SchemeName] = FtpUri; //FTP
FileUri = new BuiltInUriParser("file", NoDefaultPort, s_fileSyntaxFlags);
s_table[FileUri.SchemeName] = FileUri; //FILE
GopherUri = new BuiltInUriParser("gopher", 70, GopherSyntaxFlags);
s_table[GopherUri.SchemeName] = GopherUri; //GOPHER
NntpUri = new BuiltInUriParser("nntp", 119, NntpSyntaxFlags);
s_table[NntpUri.SchemeName] = NntpUri; //NNTP
NewsUri = new BuiltInUriParser("news", NoDefaultPort, NewsSyntaxFlags);
s_table[NewsUri.SchemeName] = NewsUri; //NEWS
MailToUri = new BuiltInUriParser("mailto", 25, MailtoSyntaxFlags);
s_table[MailToUri.SchemeName] = MailToUri; //MAILTO
UuidUri = new BuiltInUriParser("uuid", NoDefaultPort, NewsUri._flags);
s_table[UuidUri.SchemeName] = UuidUri; //UUID cloned from NEWS
TelnetUri = new BuiltInUriParser("telnet", 23, TelnetSyntaxFlags);
s_table[TelnetUri.SchemeName] = TelnetUri; //TELNET
LdapUri = new BuiltInUriParser("ldap", 389, LdapSyntaxFlags);
s_table[LdapUri.SchemeName] = LdapUri; //LDAP
NetTcpUri = new BuiltInUriParser("net.tcp", 808, NetTcpSyntaxFlags);
s_table[NetTcpUri.SchemeName] = NetTcpUri;
NetPipeUri = new BuiltInUriParser("net.pipe", NoDefaultPort, NetPipeSyntaxFlags);
s_table[NetPipeUri.SchemeName] = NetPipeUri;
VsMacrosUri = new BuiltInUriParser("vsmacros", NoDefaultPort, VsmacrosSyntaxFlags);
s_table[VsMacrosUri.SchemeName] = VsMacrosUri; //VSMACROS
}
示例11: Compress
//
// This will compress any "\" "/../" "/./" "///" "/..../" /XXX.../, etc found in the input
//
// The passed syntax controls whether to use aggressive compression or the one specified in RFC 2396
//
private static char[] Compress(char[] dest, ushort start, ref int destLength, UriParser syntax)
{
ushort slashCount = 0;
ushort lastSlash = 0;
ushort dotCount = 0;
ushort removeSegments = 0;
unchecked
{
//ushort i == -1 and start == -1 overflow is ok here
ushort i = (ushort)((ushort)destLength - (ushort)1);
start = (ushort)(start - 1);
for (; i != start; --i)
{
char ch = dest[i];
if (ch == '\\' && syntax.InFact(UriSyntaxFlags.ConvertPathSlashes))
{
dest[i] = ch = '/';
}
//
// compress multiple '/' for file URI
//
if (ch == '/')
{
++slashCount;
}
else
{
if (slashCount > 1)
{
// else preserve repeated slashes
lastSlash = (ushort)(i + 1);
}
slashCount = 0;
}
if (ch == '.')
{
++dotCount;
continue;
}
else if (dotCount != 0)
{
bool skipSegment = syntax.NotAny(UriSyntaxFlags.CanonicalizeAsFilePath)
&& (dotCount > 2 || ch != '/' || i == start);
//
// Cases:
// /./ = remove this segment
// /../ = remove this segment, mark next for removal
// /....x = DO NOT TOUCH, leave as is
// x.../ = DO NOT TOUCH, leave as is, except for V2 legacy mode
//
if (!skipSegment && ch == '/')
{
if ((lastSlash == i + dotCount + 1 // "/..../"
|| (lastSlash == 0 && i + dotCount + 1 == destLength)) // "/..."
&& (dotCount <= 2))
{
//
// /./ or /.<eos> or /../ or /..<eos>
//
// just reusing a variable slot we perform //dest.Remove(i+1, dotCount + (lastSlash==0?0:1));
lastSlash = (ushort)(i + 1 + dotCount + (lastSlash == 0 ? 0 : 1));
Buffer.BlockCopy(dest, lastSlash << 1, dest, (i + 1) << 1, (destLength - lastSlash) << 1);
destLength -= (lastSlash - i - 1);
lastSlash = i;
if (dotCount == 2)
{
//
// We have 2 dots in between like /../ or /..<eos>,
// Mark next segment for removal and remove this /../ or /..
//
++removeSegments;
}
dotCount = 0;
continue;
}
}
// .NET 4.5 no longer removes trailing dots in a path segment x.../ or x...<eos>
dotCount = 0;
//
// Here all other cases go such as
// x.[..]y or /.[..]x or (/x.[...][/] && removeSegments !=0)
}
//
// Now we may want to remove a segment because of previous /../
//
if (ch == '/')
{
//.........这里部分代码省略.........
示例12: CheckAuthorityHelperHandleAnyHostIri
private unsafe void CheckAuthorityHelperHandleAnyHostIri(char* pString, int startInput, int end,
bool iriParsing, bool hasUnicode, UriParser syntax,
ref Flags flags, ref string newHost, ref ParsingError err)
{
if (StaticNotAny(flags, Flags.HostUnicodeNormalized) && (AllowIdnStatic(syntax, flags) ||
(iriParsing && hasUnicode)))
{
// Normalize any other host or do idn
string user = new string(pString, startInput, end - startInput);
if (AllowIdnStatic(syntax, flags))
{
bool allAscii = true;
bool atLeastOneIdn = false;
string UniEquvlt = DomainNameHelper.UnicodeEquivalent(pString, startInput, end, ref allAscii,
ref atLeastOneIdn);
if (((allAscii && atLeastOneIdn) || !allAscii) && !(iriParsing && hasUnicode))
{
// original string location changed lazily
_originalUnicodeString = _string;
newHost = _originalUnicodeString.Substring(0, startInput);
flags |= Flags.HasUnicode;
}
if (atLeastOneIdn || !allAscii)
{
newHost += UniEquvlt;
string bidiStrippedHost = null;
_dnsSafeHost = DomainNameHelper.IdnEquivalent(pString, startInput, end, ref allAscii,
ref bidiStrippedHost);
if (atLeastOneIdn)
flags |= Flags.IdnHost;
if (!allAscii)
flags |= Flags.UnicodeHost;
}
else if (iriParsing && hasUnicode)
{
newHost += user;
}
}
else
{
try
{
newHost += user.Normalize(NormalizationForm.FormC);
}
catch (ArgumentException)
{
err = ParsingError.BadHostName;
}
}
flags |= Flags.HostUnicodeNormalized;
}
}
示例13: CheckAuthorityHelperHandleDnsIri
private unsafe void CheckAuthorityHelperHandleDnsIri(char* pString, ushort start, int end, int startInput,
bool iriParsing, bool hasUnicode, UriParser syntax, string userInfoString, ref Flags flags,
ref bool justNormalized, ref string newHost, ref ParsingError err)
{
// comes here only if host has unicode chars and iri is on or idn is allowed
flags |= Flags.DnsHostType;
// check if intranet
//
if ((s_IdnScope == UriIdnScope.AllExceptIntranet) && IsIntranet(new string(pString, 0, end)))
{
flags |= Flags.IntranetUri;
}
if (AllowIdnStatic(syntax, flags))
{
bool allAscii = true;
bool atLeastOneIdn = false;
string idnValue = DomainNameHelper.IdnEquivalent(pString, start, end, ref allAscii, ref atLeastOneIdn);
string UniEquvlt = DomainNameHelper.UnicodeEquivalent(idnValue, pString, start, end);
if (!allAscii)
flags |= Flags.UnicodeHost; // we have a unicode host
if (atLeastOneIdn)
flags |= Flags.IdnHost; // we have at least one valid idn label
if (allAscii && atLeastOneIdn && StaticNotAny(flags, Flags.HasUnicode))
{
// original string location changed lazily
_originalUnicodeString = _string;
newHost = _originalUnicodeString.Substring(0, startInput) +
(StaticInFact(flags, Flags.HasUserInfo) ? userInfoString : null);
justNormalized = true;
}
else if (!iriParsing && (StaticInFact(flags, Flags.UnicodeHost) || StaticInFact(flags, Flags.IdnHost)))
{
// original string location changed lazily
_originalUnicodeString = _string;
newHost = _originalUnicodeString.Substring(0, startInput) +
(StaticInFact(flags, Flags.HasUserInfo) ? userInfoString : null);
justNormalized = true;
}
if (!(allAscii && !atLeastOneIdn))
{
_dnsSafeHost = idnValue;
newHost += UniEquvlt;
justNormalized = true;
}
else if (allAscii && !atLeastOneIdn && iriParsing && hasUnicode)
{
newHost += UniEquvlt;
justNormalized = true;
}
}
else
{
if (hasUnicode)
{
string temp = UriHelper.StripBidiControlCharacter(pString, start, end - start);
try
{
newHost += ((temp != null) ? temp.Normalize(NormalizationForm.FormC) : null);
}
catch (ArgumentException)
{
err = ParsingError.BadHostName;
}
justNormalized = true;
}
}
flags |= Flags.HostUnicodeNormalized;
}
示例14: IriParsingStatic
private static bool IriParsingStatic(UriParser syntax)
{
if (!s_IriParsing)
{
return false;
}
return (((syntax != null) && syntax.InFact(UriSyntaxFlags.AllowIriParsing)) || (syntax == null));
}
示例15: CheckSchemeSyntax
private static unsafe ParsingError CheckSchemeSyntax(char* ptr, ushort length, ref UriParser syntax)
{
char ch = ptr[0];
if ((ch < 'a') || (ch > 'z'))
{
if ((ch < 'A') || (ch > 'Z'))
{
return ParsingError.BadScheme;
}
ptr[0] = (char) (ch | ' ');
}
for (ushort i = 1; i < length; i = (ushort) (i + 1))
{
char ch2 = ptr[i];
if ((ch2 < 'a') || (ch2 > 'z'))
{
if ((ch2 >= 'A') && (ch2 <= 'Z'))
{
ptr[i] = (char) (ch2 | ' ');
}
else if (((ch2 < '0') || (ch2 > '9')) && (((ch2 != '+') && (ch2 != '-')) && (ch2 != '.')))
{
return ParsingError.BadScheme;
}
}
}
string lwrCaseScheme = new string(ptr, 0, length);
syntax = UriParser.FindOrFetchAsUnknownV1Syntax(lwrCaseScheme);
return ParsingError.None;
}