From d44cda11bf435b7687fada29946d4a1cecbc728c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Ekl=C3=B6f?= Date: Sun, 14 Feb 2021 13:28:42 +0100 Subject: [PATCH] =?UTF-8?q?osc-8:=20fix=20thinko:=20can=E2=80=99t=20use=20?= =?UTF-8?q?the=20ID=20parameters=20*address*=20as=20actual=20ID?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Doing so means the next OSC-8 URL emitted by the client application, with the same ID, will get a *new* id internally. Instead, hash the string and use that as ID. --- osc.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/osc.c b/osc.c index b57bdd6c..bf97db52 100644 --- a/osc.c +++ b/osc.c @@ -16,6 +16,7 @@ #include "selection.h" #include "terminal.h" #include "uri.h" +#include "util.h" #include "vt.h" #include "xmalloc.h" #include "xsnprintf.h" @@ -409,8 +410,6 @@ osc_uri(struct terminal *term, char *string) const char *uri = params_end + 1; uint64_t id = (uint64_t)rand() << 32 | rand(); - LOG_DBG("params=%s, URI=%s", params, uri); - char *ctx = NULL; for (const char *key_value = strtok_r(params, ":", &ctx); key_value != NULL; @@ -424,12 +423,13 @@ osc_uri(struct terminal *term, char *string) *operator = '\0'; const char *value = operator + 1; - LOG_DBG("param: %s=%s", key, value); if (strcmp(key, "id") == 0) - id = (uintptr_t)value; + id = sdbm_hash(value); } + LOG_DBG("OSC-8: URL=%s, id=%" PRIu64, uri, id); + if (uri[0] == '\0') term_osc8_close(term); else