diff options
Diffstat (limited to 'OpenKeychain')
4 files changed, 27 insertions, 18 deletions
diff --git a/OpenKeychain/build.gradle b/OpenKeychain/build.gradle index c18c4865c..fd0c4c6ba 100644 --- a/OpenKeychain/build.gradle +++ b/OpenKeychain/build.gradle @@ -19,7 +19,7 @@ dependencies { compile project(':extern:spongycastle:prov') compile project(':extern:AppMsg:library') compile project(':extern:SuperToasts:supertoasts') - compile project(':extern:dnsjava') + compile project(':extern:minidns') compile project(':extern:KeybaseLib:Lib') diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/helper/EmailKeyHelper.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/helper/EmailKeyHelper.java index 80f52f914..5d281d5b0 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/helper/EmailKeyHelper.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/helper/EmailKeyHelper.java @@ -57,11 +57,13 @@ public class EmailKeyHelper { } } - // Most users don't have the SRV record, so ask a default server as well - String[] servers = Preferences.getPreferences(context).getKeyServers(); - if (servers != null && servers.length != 0) { - HkpKeyserver hkp = new HkpKeyserver(servers[0]); - keys.addAll(getEmailKeys(mail, hkp)); + if (keys.isEmpty()) { + // Most users don't have the SRV record, so ask a default server as well + String[] servers = Preferences.getPreferences(context).getKeyServers(); + if (servers != null && servers.length != 0) { + HkpKeyserver hkp = new HkpKeyserver(servers[0]); + keys.addAll(getEmailKeys(mail, hkp)); + } } return new ArrayList<ImportKeysListEntry>(keys); } diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/keyimport/HkpKeyserver.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/keyimport/HkpKeyserver.java index 2ec9e1c07..e49085a0e 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/keyimport/HkpKeyserver.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/keyimport/HkpKeyserver.java @@ -18,6 +18,10 @@ package org.sufficientlysecure.keychain.keyimport; +import de.measite.minidns.Client; +import de.measite.minidns.Question; +import de.measite.minidns.Record; +import de.measite.minidns.record.SRV; import org.apache.http.HttpEntity; import org.apache.http.HttpResponse; import org.apache.http.HttpStatus; @@ -33,10 +37,6 @@ import org.sufficientlysecure.keychain.Constants; import org.sufficientlysecure.keychain.pgp.PgpHelper; import org.sufficientlysecure.keychain.pgp.PgpKeyHelper; import org.sufficientlysecure.keychain.util.Log; -import org.xbill.DNS.Lookup; -import org.xbill.DNS.Record; -import org.xbill.DNS.SRVRecord; -import org.xbill.DNS.Type; import java.io.IOException; import java.io.InputStream; @@ -316,6 +316,12 @@ public class HkpKeyserver extends Keyserver { while (uidMatcher.find()) { String tmp = uidMatcher.group(1).trim(); if (tmp.contains("%")) { + if(tmp.contains("%%")) { + // This is a fix for issue #683 + // The server encodes a percent sign as %%, so it is swapped out with its + // urlencoded counterpart to prevent errors + tmp = tmp.replace("%%", "%25"); + } try { // converts Strings like "Universit%C3%A4t" to a proper encoding form "Universität". tmp = (URLDecoder.decode(tmp, "UTF8")); @@ -396,19 +402,20 @@ public class HkpKeyserver extends Keyserver { */ public static HkpKeyserver resolve(String domain) { try { - Record[] records = new Lookup("_hkp._tcp." + domain, Type.SRV).run(); + Record[] records = new Client().query(new Question("_hkp._tcp." + domain, Record.TYPE.SRV)).getAnswers(); if (records.length > 0) { Arrays.sort(records, new Comparator<Record>() { @Override public int compare(Record lhs, Record rhs) { - if (!(lhs instanceof SRVRecord)) return 1; - if (!(rhs instanceof SRVRecord)) return -1; - return ((SRVRecord) lhs).getPriority() - ((SRVRecord) rhs).getPriority(); + if (lhs.getPayload().getType() != Record.TYPE.SRV) return 1; + if (rhs.getPayload().getType() != Record.TYPE.SRV) return -1; + return ((SRV) lhs.getPayload()).getPriority() - ((SRV) rhs.getPayload()).getPriority(); } }); Record record = records[0]; // This is our best choice - if (record instanceof SRVRecord) { - return new HkpKeyserver(((SRVRecord) record).getTarget().toString(), (short) ((SRVRecord) record).getPort()); + if (record.getPayload().getType() == Record.TYPE.SRV) { + return new HkpKeyserver(((SRV) record.getPayload()).getName(), + (short) ((SRV) record.getPayload()).getPort()); } } } catch (Exception ignored) { diff --git a/OpenKeychain/src/main/res/values/strings.xml b/OpenKeychain/src/main/res/values/strings.xml index e24ac6925..a6b16a421 100644 --- a/OpenKeychain/src/main/res/values/strings.xml +++ b/OpenKeychain/src/main/res/values/strings.xml @@ -10,7 +10,7 @@ <string name="title_create_key">Create Key</string> <string name="title_edit_key">Edit Key</string> <string name="title_preferences">Preferences</string> - <string name="title_api_registered_apps">Registered Applications</string> + <string name="title_api_registered_apps">Apps</string> <string name="title_key_server_preference">Keyserver Preference</string> <string name="title_change_passphrase">Change Passphrase</string> <string name="title_set_passphrase">Set Passphrase</string> @@ -476,7 +476,7 @@ <string name="nav_encrypt">Sign and Encrypt</string> <string name="nav_decrypt">Decrypt and Verify</string> <string name="nav_import">Import Keys</string> - <string name="nav_apps">Registered Apps</string> + <string name="nav_apps">Apps</string> <string name="drawer_open">Open navigation drawer</string> <string name="drawer_close">Close navigation drawer</string> <string name="edit">Edit</string> |