"GOT", but the "O" is a cute, smiling pufferfish. Index | Thread | Search

From:
"Omar Polo" <op@omarpolo.com>
Subject:
fix tp_urlescape() escaping
To:
gameoftrees@openbsd.org
Date:
Sun, 02 Aug 2026 22:28:57 +0200

Download raw body.

Thread
  • Omar Polo:

    fix tp_urlescape() escaping

spotted while looking for something different in a different repository,
copy-paste is golden.

tp_urlescape() is space-padding instead of zero-padding, fix is trivial.

ok?

diff /home/op/w/got
path + /home/op/w/got
commit - c3f50630385142d9b8e1f024294037c21ea4ac5c
blob - a462a35fdd53ed1e7997e205fd621e462ad511bc
file + template/tmpl.c
--- template/tmpl.c
+++ template/tmpl.c
@@ -83,7 +83,7 @@ tp_urlescape(struct template *tp, const char *str)
 		if (iscntrl((unsigned char)*str) ||
 		    isspace((unsigned char)*str) ||
 		    *str == '\'' || *str == '"' || *str == '\\') {
-			r = snprintf(tmp, sizeof(tmp), "%%%2X", *str);
+			r = snprintf(tmp, sizeof(tmp), "%%%02X", *str);
 			if (r < 0  || (size_t)r >= sizeof(tmp))
 				return (0);
 			if (tp_write(tp, tmp, r) == -1)