Fixing edge cases that @string references passed in path parts.
Bug: b/241114745
Test: Added and verified affected atests pass
Change-Id: Ia7048222bf91aa3ce02e090789e9af05bbed97e1
diff --git a/tools/aapt2/link/ManifestFixer.cpp b/tools/aapt2/link/ManifestFixer.cpp
index df09e47..d0850b8 100644
--- a/tools/aapt2/link/ManifestFixer.cpp
+++ b/tools/aapt2/link/ManifestFixer.cpp
@@ -69,7 +69,9 @@
StringPiece attr_value = attr->value;
const char* startChar = attr_value.begin();
if (attr_name == "pathPattern") {
- if (*startChar == '/' || *startChar == '.' || *startChar == '*') {
+ // pathPattern starts with '.' or '*' does not need leading slash.
+ // Reference starts with @ does not need leading slash.
+ if (*startChar == '/' || *startChar == '.' || *startChar == '*' || *startChar == '@') {
return true;
} else {
diag->Error(android::DiagMessage(data_el->line_number)
@@ -80,7 +82,8 @@
return false;
}
} else {
- if (*startChar == '/') {
+ // Reference starts with @ does not need leading slash.
+ if (*startChar == '/' || *startChar == '@') {
return true;
} else {
diag->Error(android::DiagMessage(data_el->line_number)