1
0
mirror of https://github.com/moparisthebest/k-9 synced 2024-11-27 11:42:16 -05:00

Treat mailto-URI parameters case-insensitive

RFC 6068 defines these parameters case-insensitive, yet we only
supported lower-case values because the method Uri.getQueryParameters()
treats parameter names case-sensitive.
This patch introduces a wrapper class that implements case-insensitive
parameter name matching.

Note: commit message edited by cketti
This commit is contained in:
András Veres-Szentkirályi 2012-11-12 23:41:06 +01:00 committed by cketti
parent 900959c0d5
commit a86354be7d

View File

@ -3257,7 +3257,8 @@ public class MessageCompose extends K9Activity implements OnClickListener, OnFoc
* creating a new hierarchical dummy Uri object with the query
* parameters of the original URI.
*/
Uri uri = Uri.parse("foo://bar?" + mailtoUri.getEncodedQuery());
CaseInsensitiveParamWrapper uri = new CaseInsensitiveParamWrapper(
Uri.parse("foo://bar?" + mailtoUri.getEncodedQuery()));
// Read additional recipients from the "to" parameter.
List<String> to = uri.getQueryParameters("to");
@ -3291,6 +3292,24 @@ public class MessageCompose extends K9Activity implements OnClickListener, OnFoc
}
}
private static class CaseInsensitiveParamWrapper {
private final Uri uri;
public CaseInsensitiveParamWrapper(Uri uri) {
this.uri = uri;
}
public List<String> getQueryParameters(String key) {
final List<String> params = new ArrayList<String>();
for (String paramName : uri.getQueryParameterNames()) {
if (paramName.equalsIgnoreCase(key)) {
params.addAll(uri.getQueryParameters(paramName));
}
}
return params;
}
}
private class SendMessageTask extends AsyncTask<Void, Void, Void> {
@Override
protected Void doInBackground(Void... params) {