Fixing edge cases that @string references passed in path parts.
Bug: b/241114745 Test: Added and verified affected atests pass Change-Id: Ia7048222bf91aa3ce02e090789e9af05bbed97e1
This commit is contained in:
@@ -69,7 +69,9 @@ static bool VerifyDeeplinkPathAttribute(xml::Element* data_el, android::SourcePa
|
||||
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 @@ static bool VerifyDeeplinkPathAttribute(xml::Element* data_el, android::SourcePa
|
||||
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)
|
||||
|
||||
@@ -1408,5 +1408,24 @@ TEST_F(ManifestFixerTest, IntentFilterPathMustStartWithLeadingSlashOnDeepLinks)
|
||||
</application>
|
||||
</manifest>)";
|
||||
EXPECT_THAT(Verify(input), NotNull());
|
||||
|
||||
// DeepLink with string reference as a path.
|
||||
input = R"(
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
package="android">
|
||||
<application>
|
||||
<activity android:name=".MainActivity">
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.VIEW" />
|
||||
<category android:name="android.intent.category.DEFAULT" />
|
||||
<category android:name="android.intent.category.BROWSABLE" />
|
||||
<data android:scheme="http"
|
||||
android:host="www.example.com"
|
||||
android:path="@string/startup_uri" />
|
||||
</intent-filter>
|
||||
</activity>
|
||||
</application>
|
||||
</manifest>)";
|
||||
EXPECT_THAT(Verify(input), NotNull());
|
||||
}
|
||||
} // namespace aapt
|
||||
|
||||
Reference in New Issue
Block a user