encode and decode % and # in invite links
This commit is contained in:
parent
9b73029267
commit
77fc8d2d9e
|
@ -6,9 +6,6 @@ import android.os.SystemClock;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
import android.util.Pair;
|
import android.util.Pair;
|
||||||
|
|
||||||
import eu.siacs.conversations.Config;
|
|
||||||
import eu.siacs.conversations.crypto.PgpDecryptionService;
|
|
||||||
|
|
||||||
import org.json.JSONException;
|
import org.json.JSONException;
|
||||||
import org.json.JSONObject;
|
import org.json.JSONObject;
|
||||||
|
|
||||||
|
@ -19,7 +16,9 @@ import java.util.List;
|
||||||
import java.util.concurrent.CopyOnWriteArrayList;
|
import java.util.concurrent.CopyOnWriteArrayList;
|
||||||
import java.util.concurrent.CopyOnWriteArraySet;
|
import java.util.concurrent.CopyOnWriteArraySet;
|
||||||
|
|
||||||
|
import eu.siacs.conversations.Config;
|
||||||
import eu.siacs.conversations.R;
|
import eu.siacs.conversations.R;
|
||||||
|
import eu.siacs.conversations.crypto.PgpDecryptionService;
|
||||||
import eu.siacs.conversations.crypto.axolotl.AxolotlService;
|
import eu.siacs.conversations.crypto.axolotl.AxolotlService;
|
||||||
import eu.siacs.conversations.crypto.axolotl.XmppAxolotlSession;
|
import eu.siacs.conversations.crypto.axolotl.XmppAxolotlSession;
|
||||||
import eu.siacs.conversations.services.XmppConnectionService;
|
import eu.siacs.conversations.services.XmppConnectionService;
|
||||||
|
@ -629,7 +628,7 @@ public class Account extends AbstractEntity {
|
||||||
|
|
||||||
public String getShareableLink() {
|
public String getShareableLink() {
|
||||||
List<XmppUri.Fingerprint> fingerprints = this.getFingerprints();
|
List<XmppUri.Fingerprint> fingerprints = this.getFingerprints();
|
||||||
String uri = "https://conversations.im/i/"+this.getJid().asBareJid().toEscapedString();
|
String uri = "https://conversations.im/i/" + XmppUri.lameUrlEncode(this.getJid().asBareJid().toEscapedString());
|
||||||
if (fingerprints.size() > 0) {
|
if (fingerprints.size() > 0) {
|
||||||
return XmppUri.getFingerprintUri(uri, fingerprints, '&');
|
return XmppUri.getFingerprintUri(uri, fingerprints, '&');
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -45,6 +45,7 @@ import eu.siacs.conversations.services.XmppConnectionService.OnConversationUpdat
|
||||||
import eu.siacs.conversations.services.XmppConnectionService.OnMucRosterUpdate;
|
import eu.siacs.conversations.services.XmppConnectionService.OnMucRosterUpdate;
|
||||||
import eu.siacs.conversations.ui.util.MenuDoubleTabUtil;
|
import eu.siacs.conversations.ui.util.MenuDoubleTabUtil;
|
||||||
import eu.siacs.conversations.utils.UIHelper;
|
import eu.siacs.conversations.utils.UIHelper;
|
||||||
|
import eu.siacs.conversations.utils.XmppUri;
|
||||||
import rocks.xmpp.addr.Jid;
|
import rocks.xmpp.addr.Jid;
|
||||||
|
|
||||||
public class ConferenceDetailsActivity extends XmppActivity implements OnConversationUpdate, OnMucRosterUpdate, XmppConnectionService.OnAffiliationChanged, XmppConnectionService.OnRoleChanged, XmppConnectionService.OnConfigurationPushed {
|
public class ConferenceDetailsActivity extends XmppActivity implements OnConversationUpdate, OnMucRosterUpdate, XmppConnectionService.OnAffiliationChanged, XmppConnectionService.OnRoleChanged, XmppConnectionService.OnConfigurationPushed {
|
||||||
|
@ -298,7 +299,7 @@ public class ConferenceDetailsActivity extends XmppActivity implements OnConvers
|
||||||
protected String getShareableUri(boolean http) {
|
protected String getShareableUri(boolean http) {
|
||||||
if (mConversation != null) {
|
if (mConversation != null) {
|
||||||
if (http) {
|
if (http) {
|
||||||
return "https://conversations.im/j/" + mConversation.getJid().asBareJid().toEscapedString();
|
return "https://conversations.im/j/" + XmppUri.lameUrlEncode(mConversation.getJid().asBareJid().toEscapedString());
|
||||||
} else {
|
} else {
|
||||||
return "xmpp:" + mConversation.getJid().asBareJid() + "?join";
|
return "xmpp:" + mConversation.getJid().asBareJid() + "?join";
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,7 +10,6 @@ import android.preference.PreferenceManager;
|
||||||
import android.provider.ContactsContract.CommonDataKinds;
|
import android.provider.ContactsContract.CommonDataKinds;
|
||||||
import android.provider.ContactsContract.Contacts;
|
import android.provider.ContactsContract.Contacts;
|
||||||
import android.provider.ContactsContract.Intents;
|
import android.provider.ContactsContract.Intents;
|
||||||
import android.support.v4.content.ContextCompat;
|
|
||||||
import android.support.v7.app.AlertDialog;
|
import android.support.v7.app.AlertDialog;
|
||||||
import android.support.v7.widget.Toolbar;
|
import android.support.v7.widget.Toolbar;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
|
@ -163,11 +162,10 @@ public class ContactDetailsActivity extends OmemoActivity implements OnAccountUp
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected String getShareableUri(boolean http) {
|
protected String getShareableUri(boolean http) {
|
||||||
final String prefix = http ? "https://conversations.im/i/" : "xmpp:";
|
if (http) {
|
||||||
if (contact != null) {
|
return "https://conversations.im/j/" + XmppUri.lameUrlEncode(contact.getJid().asBareJid().toEscapedString());
|
||||||
return prefix+contact.getJid().asBareJid().toEscapedString();
|
|
||||||
} else {
|
} else {
|
||||||
return "";
|
return "xmpp:" + contact.getJid().asBareJid().toEscapedString();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
package eu.siacs.conversations.utils;
|
package eu.siacs.conversations.utils;
|
||||||
|
|
||||||
import android.net.Uri;
|
import android.net.Uri;
|
||||||
|
import android.util.Log;
|
||||||
|
|
||||||
import java.io.UnsupportedEncodingException;
|
import java.io.UnsupportedEncodingException;
|
||||||
import java.net.URLDecoder;
|
import java.net.URLDecoder;
|
||||||
|
@ -8,6 +9,7 @@ import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
|
|
||||||
|
import eu.siacs.conversations.Config;
|
||||||
import rocks.xmpp.addr.Jid;
|
import rocks.xmpp.addr.Jid;
|
||||||
|
|
||||||
public class XmppUri {
|
public class XmppUri {
|
||||||
|
@ -21,7 +23,6 @@ public class XmppUri {
|
||||||
protected boolean safeSource = true;
|
protected boolean safeSource = true;
|
||||||
|
|
||||||
public static final String OMEMO_URI_PARAM = "omemo-sid-";
|
public static final String OMEMO_URI_PARAM = "omemo-sid-";
|
||||||
public static final String OTR_URI_PARAM = "otr-fingerprint";
|
|
||||||
|
|
||||||
public static final String ACTION_JOIN = "join";
|
public static final String ACTION_JOIN = "join";
|
||||||
public static final String ACTION_MESSAGE = "message";
|
public static final String ACTION_MESSAGE = "message";
|
||||||
|
@ -60,8 +61,9 @@ public class XmppUri {
|
||||||
if (segments.size() >= 2 && segments.get(1).contains("@")) {
|
if (segments.size() >= 2 && segments.get(1).contains("@")) {
|
||||||
// sample : https://conversations.im/i/foo@bar.com
|
// sample : https://conversations.im/i/foo@bar.com
|
||||||
try {
|
try {
|
||||||
jid = Jid.of(segments.get(1)).toString();
|
jid = Jid.of(lameUrlDecode(segments.get(1))).toString();
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
Log.d(Config.LOGTAG, "parsing failed ", e);
|
||||||
jid = null;
|
jid = null;
|
||||||
}
|
}
|
||||||
} else if (segments.size() >= 3) {
|
} else if (segments.size() >= 3) {
|
||||||
|
@ -211,6 +213,7 @@ public class XmppUri {
|
||||||
public boolean hasFingerprints() {
|
public boolean hasFingerprints() {
|
||||||
return fingerprints.size() > 0;
|
return fingerprints.size() > 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
public enum FingerprintType {
|
public enum FingerprintType {
|
||||||
OMEMO
|
OMEMO
|
||||||
}
|
}
|
||||||
|
@ -253,4 +256,12 @@ public class XmppUri {
|
||||||
return type.toString() + ": " + fingerprint + (deviceId != 0 ? " " + String.valueOf(deviceId) : "");
|
return type.toString() + ": " + fingerprint + (deviceId != 0 ? " " + String.valueOf(deviceId) : "");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static String lameUrlDecode(String url) {
|
||||||
|
return url.replace("%23", "#").replace("%25", "%");
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String lameUrlEncode(String url) {
|
||||||
|
return url.replace("%", "%25").replace("#", "%23");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue