osc-8: fix thinko: can’t use the ID parameters *address* as actual ID

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.
This commit is contained in:
Daniel Eklöf 2021-02-14 13:28:42 +01:00
parent 34b814349b
commit d44cda11bf
No known key found for this signature in database
GPG key ID: 5BBD4992C116573F

8
osc.c
View file

@ -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