Properly encode XMPP URIs before sharing (Cheogram)

This commit is contained in:
Arne 2023-05-22 20:08:01 +02:00
parent 1887bd2e42
commit 6e6e784df9
3 changed files with 7 additions and 5 deletions

View file

@ -4,6 +4,7 @@ import android.content.ContentValues;
import android.database.Cursor;
import android.os.SystemClock;
import android.util.Log;
import android.net.Uri;
import com.google.common.base.Strings;
import com.google.common.collect.ImmutableList;
@ -729,7 +730,7 @@ public class Account extends AbstractEntity implements AvatarService.Avatarable
public String getShareableUri() {
List<XmppUri.Fingerprint> fingerprints = this.getFingerprints();
String uri = "xmpp:" + this.getJid().asBareJid().toEscapedString();
String uri = "xmpp:" + Uri.encode(getJid().asBareJid().toEscapedString(), "@/");
if (fingerprints.size() > 0) {
return XmppUri.getFingerprintUri(uri, fingerprints, ';');
} else {

View file

@ -12,6 +12,7 @@ import java.util.Map;
import java.util.stream.Collectors;
import eu.siacs.conversations.entities.Contact;
import eu.siacs.conversations.entities.ListItem;
import android.net.Uri;
import android.app.Activity;
import android.app.PendingIntent;
@ -515,9 +516,9 @@ public class ConferenceDetailsActivity extends XmppActivity implements OnConvers
protected String getShareableUri(boolean http) {
if (mConversation != null) {
if (http) {
return Config.inviteMUCURL + XmppUri.lameUrlEncode(mConversation.getJid().asBareJid().toEscapedString());
return "https://conversations.im/j/" + XmppUri.lameUrlEncode(mConversation.getJid().asBareJid().toEscapedString());
} else {
return "xmpp:" + mConversation.getJid().asBareJid().toEscapedString() + "?join";
return "xmpp:" + Uri.encode(mConversation.getJid().asBareJid().toEscapedString(), "@/") + "?join";
}
} else {
return null;

View file

@ -268,9 +268,9 @@ public class ContactDetailsActivity extends OmemoActivity implements OnAccountUp
@Override
protected String getShareableUri(boolean http) {
if (http) {
return Config.inviteUserURL + XmppUri.lameUrlEncode(contact.getJid().asBareJid().toEscapedString());
return "https://conversations.im/i/" + XmppUri.lameUrlEncode(contact.getJid().asBareJid().toEscapedString());
} else {
return "xmpp:" + contact.getJid().asBareJid().toEscapedString();
return "xmpp:" + Uri.encode(contact.getJid().asBareJid().toEscapedString(), "@/");
}
}