0
0
mirror of https://github.com/TrianguloY/UrlChecker.git synced 2024-09-19 20:02:16 +02:00

try to open more valid urls, specially those with incorrect schema case

hopefully closes #258
This commit is contained in:
TrianguloY 2023-08-15 12:58:33 +02:00
parent 9c91f2c67f
commit 50c510954f
4 changed files with 31 additions and 6 deletions

View File

@ -39,23 +39,39 @@
<data android:scheme="http" />
<data android:scheme="https" />
<!-- Invalid by the android schema, but some apps do send them -->
<data android:scheme="Http" />
<data android:scheme="Https" />
<data android:scheme="HTTP" />
<data android:scheme="HTTPS" />
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.BROWSABLE" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:scheme="http" />
<data android:scheme="https" />
<data android:mimeType="text/html" />
<data android:mimeType="text/plain" />
<data android:mimeType="application/xhtml+xml" />
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.SEND" />
<category android:name="android.intent.category.DEFAULT" />
<data android:mimeType="text/plain" />
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.APP_BROWSER" />
</intent-filter>
</activity>
<activity
android:name=".activities.MainActivity"

View File

@ -337,14 +337,11 @@ public class MainDialog extends Activity {
var links = AndroidUtils.getLinksFromText(sharedText);
if (links.isEmpty()) links.add(sharedText.trim()); // no links? just use the whole text, the user requested the app so...
return links;
} else if (Intent.ACTION_VIEW.equals(action)) {
// view url
} else {
// other, check data
var uri = intent.getData();
if (uri == null) return Collections.emptySet();
return Collections.singleton(uri.toString());
} else {
// other
return Collections.emptySet();
}
}

View File

@ -39,6 +39,16 @@ public class PatternCatalog extends JsonCatalog {
.put("regex", "^(?!.*:)")
.put("replacement", "https://$0")
)
.put(cntx.getString(R.string.mPttrn_wrongSchemaHttp), new JSONObject()
.put("regex", "^(?!http:)[hH][tT]{2}[pP]:(.*)")
.put("replacement", "http:$1")
.put("automatic", "true")
)
.put(cntx.getString(R.string.mPttrn_wrongSchemaHttps), new JSONObject()
.put("regex", "^(?!https:)[hH][tT]{2}[pP][sS]:(.*)")
.put("replacement", "https:$1")
.put("automatic", "true")
)
// privacy redirections samples (see https://github.com/TrianguloY/UrlChecker/discussions/122)
.put("Reddit ➔ Teddit", new JSONObject()

View File

@ -128,6 +128,8 @@ Built-in patterns include:
<string name="mPttrn_http">HTTP link. Consider using HTTPS.</string>
<string name="mPttrn_noSchemeHttp">Missing HTTP scheme.</string>
<string name="mPttrn_noSchemeHttps">Missing HTTPS scheme.</string>
<string name="mPttrn_wrongSchemaHttp">Invalid http scheme case.</string>
<string name="mPttrn_wrongSchemaHttps">Invalid https scheme case.</string>
<string name="mPttrn_ok">No matching patterns</string>
<string name="mPttrn_editor">"Here you can edit or add new pattern. Format:
- 'encode': boolean: set to true to encode the url before checking regex.