Loading tools/aapt2/link/ManifestFixer.cpp +5 −2 Original line number Diff line number Diff line Loading @@ -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) Loading @@ -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) Loading tools/aapt2/link/ManifestFixer_test.cpp +19 −0 Original line number Diff line number Diff line Loading @@ -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 Loading
tools/aapt2/link/ManifestFixer.cpp +5 −2 Original line number Diff line number Diff line Loading @@ -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) Loading @@ -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) Loading
tools/aapt2/link/ManifestFixer_test.cpp +19 −0 Original line number Diff line number Diff line Loading @@ -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