mirror of
https://github.com/M66B/FairEmail.git
synced 2025-01-04 06:20:26 +00:00
Sanitize query: preserve keys without values
This commit is contained in:
parent
bcf8c93f01
commit
0db20e8806
1 changed files with 33 additions and 20 deletions
|
@ -419,31 +419,44 @@ public class UriHelper {
|
||||||
path = path.toLowerCase(Locale.ROOT);
|
path = path.toLowerCase(Locale.ROOT);
|
||||||
|
|
||||||
boolean first = "www.facebook.com".equals(host);
|
boolean first = "www.facebook.com".equals(host);
|
||||||
for (String key : url.getQueryParameterNames()) {
|
String q = url.getEncodedQuery();
|
||||||
// https://en.wikipedia.org/wiki/UTM_parameters
|
if (q != null) {
|
||||||
// https://docs.oracle.com/en/cloud/saas/marketing/eloqua-user/Help/EloquaAsynchronousTrackingScripts/EloquaTrackingParameters.htm
|
StringBuilder sb = new StringBuilder();
|
||||||
String lkey = key.toLowerCase(Locale.ROOT);
|
for (String kv : q.split("&")) {
|
||||||
if (PARANOID_QUERY.contains(lkey) ||
|
int eq = kv.indexOf('=');
|
||||||
lkey.startsWith("utm_") ||
|
String key = (eq < 0 ? kv : kv.substring(0, eq));
|
||||||
lkey.startsWith("elq") ||
|
String value = (eq < 0 ? null : kv.substring(eq + 1));
|
||||||
((host != null && host.endsWith("facebook.com")) &&
|
|
||||||
!first &&
|
// https://en.wikipedia.org/wiki/UTM_parameters
|
||||||
FACEBOOK_WHITELIST_PATH.contains(path) &&
|
// https://docs.oracle.com/en/cloud/saas/marketing/eloqua-user/Help/EloquaAsynchronousTrackingScripts/EloquaTrackingParameters.htm
|
||||||
!FACEBOOK_WHITELIST_QUERY.contains(lkey)) ||
|
String lkey = key.toLowerCase(Locale.ROOT);
|
||||||
("store.steampowered.com".equals(host) &&
|
if (PARANOID_QUERY.contains(lkey) ||
|
||||||
"snr".equals(lkey)))
|
lkey.startsWith("utm_") ||
|
||||||
changed = true;
|
lkey.startsWith("elq") ||
|
||||||
else if (!TextUtils.isEmpty(key))
|
((host != null && host.endsWith("facebook.com")) &&
|
||||||
for (String value : url.getQueryParameters(key)) {
|
!first &&
|
||||||
Log.i("Query " + key + "=" + value);
|
FACEBOOK_WHITELIST_PATH.contains(path) &&
|
||||||
Uri suri = Uri.parse(value);
|
!FACEBOOK_WHITELIST_QUERY.contains(lkey)) ||
|
||||||
|
("store.steampowered.com".equals(host) &&
|
||||||
|
"snr".equals(lkey)))
|
||||||
|
changed = true;
|
||||||
|
else if (!TextUtils.isEmpty(key)) {
|
||||||
|
Uri suri = Uri.parse(key);
|
||||||
if (suri != null && isHyperLink(suri)) {
|
if (suri != null && isHyperLink(suri)) {
|
||||||
Uri s = sanitize(context, suri);
|
Uri s = sanitize(context, suri);
|
||||||
return (s == null ? suri : s);
|
return (s == null ? suri : s);
|
||||||
}
|
}
|
||||||
builder.appendQueryParameter(key, value);
|
if (sb.length() > 0)
|
||||||
|
sb.append('&');
|
||||||
|
sb.append(key);
|
||||||
|
if (value != null) {
|
||||||
|
sb.append('=').append(value);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
first = false;
|
first = false;
|
||||||
|
}
|
||||||
|
if (sb.length() > 0)
|
||||||
|
builder.encodedQuery(sb.toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
return (changed ? builder.build() : null);
|
return (changed ? builder.build() : null);
|
||||||
|
|
Loading…
Reference in a new issue