-
Notifications
You must be signed in to change notification settings - Fork 4.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Extra tests for assembly name parser. #64022
Changes from 13 commits
d5cabde
8ed4c9c
9aaf6aa
2f4289e
79df408
e21919a
03c5fd1
9fe73fb
b75170c
8442113
5f3f989
46322e3
cac53a9
c8bc069
f4beac6
88625e5
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -30,12 +30,9 @@ namespace BINDER_SPACE | |
IDENTITY_FLAG_PUBLIC_KEY_TOKEN = 0x004, | ||
IDENTITY_FLAG_PUBLIC_KEY = 0x008, | ||
IDENTITY_FLAG_CULTURE = 0x010, | ||
IDENTITY_FLAG_LANGUAGE = 0x020, | ||
IDENTITY_FLAG_PROCESSOR_ARCHITECTURE = 0x040, | ||
IDENTITY_FLAG_RETARGETABLE = 0x080, | ||
IDENTITY_FLAG_PUBLIC_KEY_TOKEN_NULL = 0x100, | ||
IDENTITY_FLAG_CUSTOM = 0x200, | ||
IDENTITY_FLAG_CUSTOM_NULL = 0x400, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. IDENTITY_FLAG_CUSTOM was to support "custom" attribute that would have a binary blob as a value. We would not use the blob for anything. Managed Modulo validation that "custom" is not duplicated and the blob content is a valid hex, it is not any different from the treatment of unrecognized attributes. |
||
IDENTITY_FLAG_CONTENT_TYPE = 0x800, | ||
IDENTITY_FLAG_FULL_NAME = (IDENTITY_FLAG_SIMPLE_NAME | | ||
IDENTITY_FLAG_VERSION) | ||
|
@@ -50,7 +47,6 @@ namespace BINDER_SPACE | |
// Need to pre-populate SBuffers because of bogus asserts | ||
static const BYTE byteArr[] = { 0 }; | ||
m_publicKeyOrTokenBLOB.SetImmutable(byteArr, sizeof(byteArr)); | ||
m_customBLOB.SetImmutable(byteArr, sizeof(byteArr)); | ||
} | ||
~AssemblyIdentity() | ||
{ | ||
|
@@ -83,7 +79,6 @@ namespace BINDER_SPACE | |
SBuffer m_publicKeyOrTokenBLOB; | ||
PEKIND m_kProcessorArchitecture; | ||
AssemblyContentType m_kContentType; | ||
SBuffer m_customBLOB; | ||
DWORD m_dwIdentityFlags; | ||
}; | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -25,12 +25,10 @@ StringLexer::~StringLexer() | |
// Nothing to do here | ||
} | ||
|
||
void StringLexer::Init(SString &inputString, BOOL fSupportEscaping) | ||
void StringLexer::Init(SString &inputString) | ||
{ | ||
m_cursor = inputString.Begin(); | ||
m_end = inputString.End(); | ||
m_fSupportEscaping = fSupportEscaping; | ||
m_fReadRawCharacter = FALSE; | ||
} | ||
|
||
BOOL StringLexer::IsWhitespace(WCHAR wcChar) | ||
|
@@ -55,6 +53,7 @@ WCHAR StringLexer::PopCharacter(BOOL *pfIsEscaped) | |
{ | ||
m_wcCurrentChar = INVALID_CHARACTER; | ||
*pfIsEscaped = m_fCurrentCharIsEscaped; | ||
m_cursor++; | ||
} | ||
else | ||
{ | ||
|
@@ -71,172 +70,63 @@ void StringLexer::PushCharacter(WCHAR wcCurrentChar, | |
|
||
m_wcCurrentChar = wcCurrentChar; | ||
m_fCurrentCharIsEscaped = fIsEscaped; | ||
m_cursor--; | ||
} | ||
|
||
WCHAR StringLexer::GetRawCharacter() | ||
{ | ||
WCHAR wcCurrentChar = 0; | ||
|
||
if (m_cursor <= m_end) | ||
if (m_cursor < m_end) | ||
{ | ||
wcCurrentChar = m_cursor[0]; | ||
m_fReadRawCharacter = TRUE; | ||
m_cursor++; | ||
} | ||
else | ||
{ | ||
m_fReadRawCharacter = FALSE; | ||
} | ||
|
||
return wcCurrentChar; | ||
} | ||
|
||
void StringLexer::PushRawCharacter() | ||
{ | ||
if (m_fReadRawCharacter) | ||
{ | ||
m_cursor--; | ||
m_fReadRawCharacter = FALSE; | ||
} | ||
} | ||
|
||
WCHAR StringLexer::DecodeUTF16Character() | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This was only used when lexing numbers in escaped unicode characters like |
||
{ | ||
// See http://www.ietf.org/rfc/rfc2781.txt for details on UTF-16 encoding. | ||
|
||
WCHAR wcCurrentChar = 0; | ||
SCOUNT_T nCharacters = m_end - m_cursor + 1; | ||
WCHAR wcChar1 = GetRawCharacter(); | ||
|
||
if (wcChar1 < 0xd800) | ||
{ | ||
wcCurrentChar = wcChar1; | ||
// do not allow \0 anywhere in the string. | ||
if (wcCurrentChar == 0) | ||
{ | ||
wcCurrentChar = INVALID_CHARACTER; | ||
} | ||
} | ||
else | ||
{ | ||
// StringLexer is not designed to handle UTF-16 characters beyond the Basic Multilingual Plane, | ||
// since it stores all characters in 16-bit WCHARs. | ||
// However, since the vast majority of the time, we (Microsoft) produce the manifests, | ||
// this is likely a non-scenario, as the other Unicode planes would never be used in practice. | ||
|
||
if (wcChar1 <= 0xdbff) // 0xd800 - 0xdbff indicates the first WCHAR of a surrogate pair | ||
{ | ||
if (nCharacters >= 2) | ||
{ | ||
GetRawCharacter(); // Skip the second WCHAR of the surrogate pair | ||
} | ||
} | ||
// Otherwise, the character is either in the 0xdc00 - 0xdfff range, indicating the second WCHAR of a surrogate pair, | ||
// or in the 0xE000 - 0xFFFF range, which has within it ranges of invalid characters, and which we conservatively treat | ||
// as invalid. | ||
|
||
wcCurrentChar = INVALID_CHARACTER; | ||
// EOS | ||
wcCurrentChar = 0; | ||
} | ||
|
||
return wcCurrentChar; | ||
} | ||
|
||
|
||
WCHAR StringLexer::GetNextCharacter(BOOL *pfIsEscaped) | ||
{ | ||
*pfIsEscaped = FALSE; | ||
|
||
WCHAR wcCurrentChar = GetRawCharacter(); // DecodeUTF16Character() | ||
WCHAR wcCurrentChar = GetRawCharacter(); | ||
if (wcCurrentChar == L'\\') | ||
{ | ||
WCHAR wcTempChar = GetRawCharacter(); // DecodeUTF16Character() | ||
WCHAR wcTempChar = GetRawCharacter(); | ||
|
||
if (m_fSupportEscaping) | ||
{ | ||
// Handle standard escapes | ||
switch (wcTempChar) | ||
{ | ||
case L'"': | ||
case L'\'': | ||
case L',': | ||
case L'\\': | ||
case L'/': | ||
case L'=': | ||
break; | ||
case L't': | ||
wcTempChar = 9; | ||
break; | ||
case L'n': | ||
wcTempChar = 10; | ||
break; | ||
case L'r': | ||
wcTempChar = 13; | ||
break; | ||
case L'u': | ||
wcTempChar = ParseUnicode(); | ||
break; | ||
default: | ||
return INVALID_CHARACTER; | ||
} | ||
|
||
*pfIsEscaped = TRUE; | ||
wcCurrentChar = wcTempChar; | ||
} | ||
else | ||
{ | ||
// Do not handle escapes except for quotes | ||
switch (wcTempChar) | ||
{ | ||
case L'"': | ||
case L'\'': | ||
*pfIsEscaped = TRUE; | ||
wcCurrentChar = wcTempChar; | ||
break; | ||
default: | ||
PushRawCharacter(); | ||
break; | ||
} | ||
} | ||
} | ||
|
||
return wcCurrentChar; | ||
} | ||
|
||
WCHAR StringLexer::ParseUnicode() | ||
{ | ||
int nCharacters = 0; | ||
WCHAR wcUnicodeChar = 0; | ||
|
||
for(;;) | ||
{ | ||
WCHAR wcCurrentChar = DecodeUTF16Character(); | ||
nCharacters++; | ||
|
||
if (wcCurrentChar == L';') | ||
// Handle standard escapes | ||
switch (wcTempChar) | ||
{ | ||
case L'"': | ||
case L'\'': | ||
case L',': | ||
case L'\\': | ||
case L'=': | ||
case L't': | ||
case L'n': | ||
case L'r': | ||
break; | ||
} | ||
else if ((wcCurrentChar == INVALID_CHARACTER) || (nCharacters >= 9)) | ||
{ | ||
default: | ||
return INVALID_CHARACTER; | ||
} | ||
|
||
wcUnicodeChar <<= 4; | ||
|
||
if ((wcCurrentChar >= L'0') && (wcCurrentChar <= L'9')) | ||
{ | ||
wcUnicodeChar += (wcCurrentChar - L'0'); | ||
} | ||
else if ((wcCurrentChar >= L'a') && (wcCurrentChar <= L'f')) | ||
{ | ||
wcUnicodeChar += (wcCurrentChar - L'a') + 10; | ||
} | ||
else if ((wcCurrentChar >= L'A') && (wcCurrentChar <= L'F')) | ||
{ | ||
wcUnicodeChar += (wcCurrentChar - L'A') + 10; | ||
} | ||
else | ||
{ | ||
return INVALID_CHARACTER; | ||
} | ||
*pfIsEscaped = TRUE; | ||
wcCurrentChar = wcTempChar; | ||
} | ||
|
||
return wcUnicodeChar; | ||
return wcCurrentChar; | ||
} | ||
|
||
#endif |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IDENTITY_FLAG_LANGUAGE was unused