Allow space characters in SimpleName.

DEX format allows Unicode space characters in SimpleName since version 040.
Allowed space characters include everything in Unicode category 'Zs':

  0x20, 0xa0, 0x1680, 0x2000..0x200a, 0x202f, 0x205f, 0x3000

Smali now supports symtax `method with spaces` (spaces are allowed in
backtick-quoted names).
This commit is contained in:
Ulya Trafimovich 2019-08-28 13:50:26 +01:00 committed by Ben Gruver
parent 751fe1ce61
commit 586ec594e2
3 changed files with 17 additions and 5 deletions

View File

@ -225,8 +225,11 @@ HighSurrogate = [\ud800-\udbff]
LowSurrogate = [\udc00-\udfff]
SimpleNameCharacter = ({HighSurrogate} {LowSurrogate}) | [A-Za-z0-9$\-_\u00a1-\u1fff\u2010-\u2027\u2030-\ud7ff\ue000-\uffef]
UnicodeSpace = [\u0020\u00A0\u1680\u2000-\u200A\u202F\u205F\u3000] /* Zs category */
SimpleName = {SimpleNameCharacter}+
SimpleNameRaw = {SimpleNameCharacter}+
SimpleNameQuoted = [`] ({SimpleNameCharacter} | {UnicodeSpace})+ [`]
SimpleName = {SimpleNameRaw} | {SimpleNameQuoted}
PrimitiveType = [ZBSCIJFD]
@ -682,8 +685,13 @@ Type = {PrimitiveType} | {ClassDescriptor} | {ArrayPrefix} ({ClassDescriptor} |
yybegin(PARAM_LIST);
}
{SimpleName} { return newToken(SIMPLE_NAME); }
"<" {SimpleName} ">" { return newToken(MEMBER_NAME); }
{SimpleNameRaw} { return newToken(SIMPLE_NAME); }
{SimpleNameQuoted} {
String quoted = yytext();
String raw = quoted.substring(1, quoted.length() - 1); /* strip backticks */
return newToken(SIMPLE_NAME, raw);
}
"<" {SimpleNameRaw} ">" { return newToken(MEMBER_NAME); }
}
/*Symbols/Whitespace/EOF*/

View File

@ -54,3 +54,5 @@ L[Ljava/lang/String;
III
[I->clone()Ljava/lang/Object;
`method_with_spaces_20 a0 16802000 200120022003200420052006200720082009200a202f205f3000 `

View File

@ -108,3 +108,5 @@ SIMPLE_NAME("clone")
OPEN_PAREN("(")
CLOSE_PAREN(")")
CLASS_DESCRIPTOR("Ljava/lang/Object;")
SIMPLE_NAME("method_with_spaces_20 a0 16802000 200120022003200420052006200720082009200a202f205f3000 ")