Skip to content

Commit 507ebf3

Browse files
authored
16k and add tests for mailto schemes (#4)
Task/Issue URL: https://app.asana.com/1/137249556945/project/1208671518894266/task/1211944943901842?focus=true ### Description Make sure the library is 16k page aligned for android and incidentaly add some more tests ### Steps to test this PR - [x] `rm -rf ~/.m2/repository/com/duckduckgo/` to nuke the maven local folder - [x] Build the library with `sh scripts/build_android.sh` - [x] `cd android` and then `sh release_android.sh --new-version 0.3.4 --bump patch --maven-local` -- This will release the library to maven local - [x] checkout duckduckgo/Android#7126 from Android repo - [x] Apply this patch to that branch ```diff commit 807527950e27d3b7f42978707dc902801ccad483 Author: Aitor Viana <[email protected]> Date: Sun Jun 4 20:49:52 2023 -0400 Maven local use diff --git a/build.gradle b/build.gradle index 77ae343b02..6f9f36ec38 100644 --- a/build.gradle +++ b/build.gradle @@ -41,6 +41,10 @@ allprojects { google() mavenCentral() maven { url 'https://jitpack.io' } +// maven { +// url "https://central.sonatype.com/repository/maven-snapshots/" +// } + mavenLocal() } configurations.all { resolutionStrategy.force 'org.objenesis:objenesis:2.6' commit 4b326df9339f21e83ee6584f8d560cba32dba9cb Author: Aitor Viana <[email protected]> Date: Tue Nov 18 17:04:25 2025 +0000 bump to 0.3.4 diff --git a/versions.properties b/versions.properties index 660fdf03ac..ff5fe9c003 100644 --- a/versions.properties +++ b/versions.properties @@ -86,7 +86,7 @@ version.com.duckduckgo.netguard..netguard-android=1.10.2 version.com.duckduckgo.synccrypto..sync-crypto-android=0.7.0 -version.com.duckduckgo.urlpredictor..url-predictor-android=0.3.3 +version.com.duckduckgo.urlpredictor..url-predictor-android=0.3.4 version.com.frybits.harmony..harmony=1.2.6 ``` - [x] Execute `rm -rf build-cache/; ./gradlew clean assembleID` - [ ] Then run `./scripts/check_elf_alignment.sh ./app/build/outputs/apk/internal/debug/duckduckgo-5.256.0-internal-debug.apk` or whatever the APK is - [ ] verify `liburl_predictor.so` always appear as aligned
1 parent e9bdcf4 commit 507ebf3

File tree

3 files changed

+30
-1
lines changed

3 files changed

+30
-1
lines changed

android/ddg-url-predictor/src/test/java/UrlPredictorTest.kt

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ class UrlPredictorTests {
3939
}
4040

4141
@Test
42-
fun `telephone number with intl formatting is search`() {
42+
fun `telephone number with intl forma tting is search`() {
4343
val input = "+351 912 345 678"
4444
val d = classify(input)
4545
assertTrue(d is Decision.Search)
@@ -127,4 +127,21 @@ class UrlPredictorTests {
127127
val d = classify("duck://flags")
128128
assertTrue(d is Decision.Navigate)
129129
}
130+
131+
// ------------------------------------------------------------------------
132+
// mailto URLs
133+
// ------------------------------------------------------------------------
134+
135+
@Test
136+
fun `mailto google becomes search`() {
137+
val d = classify("mailto:[email protected]")
138+
assertTrue(d is Decision.Navigate)
139+
}
140+
141+
@Test
142+
fun `mailto yahoo becomes search`() {
143+
144+
val d = classify("mailto:[email protected]")
145+
assertTrue(d is Decision.Navigate)
146+
}
130147
}

scripts/build_android.sh

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,9 @@ if [[ -n "${FEATURES}" ]]; then
6969
FEATURE_FLAGS+=(--features "${FEATURES}")
7070
fi
7171

72+
# Ensure ELF LOAD segments are aligned to at least 16KB (2**14).
73+
export RUSTFLAGS="${RUSTFLAGS:-} -C link-arg=-Wl,-z,max-page-size=0x4000 -Wl,-z,common-page-size=16384"
74+
7275
# --- Build per ABI ---
7376
for ABI in ${ABIS}; do
7477
echo "==> Building for ABI: ${ABI}"

src/lib.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -865,5 +865,14 @@ mod tests {
865865
Decision::Search { query } if query == "+351 912 345 678"
866866
));
867867
}
868+
869+
#[cfg(feature = "real-psl")]
870+
#[test]
871+
fn mailto_urls_become_search() {
872+
let p = Policy::default();
873+
assert!(matches!(classify("mailto:[email protected]", &p), Decision::Navigate { .. }));
874+
assert!(matches!(classify("mailto:[email protected]", &p), Decision::Navigate { .. }));
875+
assert!(matches!(classify("mailto:[email protected]", &p), Decision::Navigate { .. }));
876+
}
868877
}
869878

0 commit comments

Comments
 (0)