QR-code: Actually use Uri.join if glib version supports it

This commit is contained in:
fiaxh 2022-03-08 18:33:42 -06:00
parent d1c8284964
commit 5f04a6eb09
2 changed files with 8 additions and 7 deletions

View file

@ -198,7 +198,8 @@ include(${VALA_USE_FILE})
include(MultiFind)
include(GlibCompileResourcesSupport)
set(CMAKE_VALA_FLAGS "${CMAKE_VALA_FLAGS} --target-glib=${GLib_GLOBAL_VERSION}")
find_package(GLib ${GLib_GLOBAL_VERSION} REQUIRED)
set(CMAKE_VALA_FLAGS "${CMAKE_VALA_FLAGS} --target-glib=${GLib_VERSION}")
add_subdirectory(qlite)
add_subdirectory(xmpp-vala)

View file

@ -93,9 +93,9 @@ public class ContactDetailsDialog : Gtk.Dialog {
int sid = plugin.db.identity.row_with(plugin.db.identity.account_id, account.id)[plugin.db.identity.device_id];
var iri_query = @"omemo-sid-$(sid)=$(fingerprint)";
#if 0
#if GLIB_2_66
// glib >=2.66 only; never compiled
string iri = GLib.Uri.join("xmpp", null, null, 0, jid, iri_query);
string iri = GLib.Uri.join(UriFlags.NONE, "xmpp", null, null, 0, jid.to_string(), iri_query, null);
#else
var iri_path_seg = escape_for_iri_path_segment(jid.to_string());
var iri = @"xmpp:$(iri_path_seg)?$(iri_query)";
@ -136,9 +136,9 @@ public class ContactDetailsDialog : Gtk.Dialog {
private static string escape_for_iri_path_segment(string s) {
// from RFC 3986, 2.2. Reserved Characters:
/*const*/ string SUB_DELIMS = "!$&'()*+,;=";
string SUB_DELIMS = "!$&'()*+,;=";
// from RFC 3986, 3.3. Path (pchar without unreserved and pct-encoded):
/*const*/ string ALLOWED_RESERVED_CHARS = SUB_DELIMS + ":@";
string ALLOWED_RESERVED_CHARS = SUB_DELIMS + ":@";
return GLib.Uri.escape_string(s, ALLOWED_RESERVED_CHARS, true);
}