From ef140e44545d423f30e3c858e86a64d542a192da Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marek=20Ma=C5=A1karinec?= Date: Fri, 8 Mar 2024 12:12:19 +0100 Subject: [PATCH 1/2] Sanitize control characters in input str (#144) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Marek Maškarinec --- lib/sokol | 2 +- lib/umka | 2 +- src/staembed.c | 10 +++++++--- src/window.c | 3 +++ 4 files changed, 12 insertions(+), 5 deletions(-) diff --git a/lib/sokol b/lib/sokol index 55dff3d..db32cf4 160000 --- a/lib/sokol +++ b/lib/sokol @@ -1 +1 @@ -Subproject commit 55dff3d0b9f67145582e13d3b184138260cbcc98 +Subproject commit db32cf409a9eb984e1ababa96e243f141c7f40ed diff --git a/lib/umka b/lib/umka index 3b1411d..0a6d90a 160000 --- a/lib/umka +++ b/lib/umka @@ -1 +1 @@ -Subproject commit 3b1411d812b038b8ef878e65cf958823b8eb3991 +Subproject commit 0a6d90a6c41ab42a12fd946debe4e65dcb9d4bf1 diff --git a/src/staembed.c b/src/staembed.c index f2debde..cb811ca 100644 --- a/src/staembed.c +++ b/src/staembed.c @@ -1,4 +1,4 @@ -#include "tophat.h" +#include "tophat.h" const char *th_em_modulesrc[] = { "\n" "import (\n" @@ -534,7 +534,9 @@ const char *th_em_modulesrc[] = { "\n" "fn umth_image_render_target_to_image(ret: ^Image, rt: RenderTarget)\n" "//~~fn RenderTarget.toImage\n" -"// Returns the image of the render target.\n" +"// Returns the image of the render target. The resulting image has the same\n" +"// lifetime as the base RenderTarget. If you need to use it past the lifetime\n" +"// of the RenderTarget, use the copy method.\n" "// Do not call `setfilter` on the resulting image.\n" "fn (rt: ^RenderTarget) toImage*(): Image {\n" "//~~\n" @@ -4251,7 +4253,9 @@ const char *th_em_moduledocs[] = { "fn (rt: ^RenderTarget) toImage*(): Image {\n" "```\n" "\n" -"Returns the image of the render target.\n" +"Returns the image of the render target. The resulting image has the same\n" +"lifetime as the base RenderTarget. If you need to use it past the lifetime\n" +"of the RenderTarget, use the copy method.\n" "Do not call `setfilter` on the resulting image.\n" "\n" "\n" diff --git a/src/window.c b/src/window.c index 918f9e2..65f441b 100644 --- a/src/window.c +++ b/src/window.c @@ -123,6 +123,9 @@ event(const sapp_event *ev) thg->mouse = (th_vf2){.x = ev->mouse_x, .y = ev->mouse_y}; break; case SAPP_EVENTTYPE_CHAR: + if (ev->char_code < ' ') + break; + thg->input_string_len = th_utf8_encode(thg->input_string, ev->char_code); break; case SAPP_EVENTTYPE_KEY_DOWN: From 370a4e7af5ba2c0547ec1fce4de47b125acfe357 Mon Sep 17 00:00:00 2001 From: skejeton Date: Mon, 11 Mar 2024 10:27:31 -0300 Subject: [PATCH 2/2] Fix up --- lib/miniaudio | 2 +- lib/umka | 2 +- src/staembed.c | 2 +- src/window.c | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/miniaudio b/lib/miniaudio index 4a5b74b..b19cc09 160000 --- a/lib/miniaudio +++ b/lib/miniaudio @@ -1 +1 @@ -Subproject commit 4a5b74bef029b3592c54b6048650ee5f972c1a48 +Subproject commit b19cc09fd06b80f370ca4385d260df7e31925b50 diff --git a/lib/umka b/lib/umka index 0a6d90a..eb10152 160000 --- a/lib/umka +++ b/lib/umka @@ -1 +1 @@ -Subproject commit 0a6d90a6c41ab42a12fd946debe4e65dcb9d4bf1 +Subproject commit eb10152d58dea52713f41cf3a038a1faf2526e4a diff --git a/src/staembed.c b/src/staembed.c index cb811ca..ce92315 100644 --- a/src/staembed.c +++ b/src/staembed.c @@ -1,4 +1,4 @@ -#include "tophat.h" +#include "tophat.h" const char *th_em_modulesrc[] = { "\n" "import (\n" diff --git a/src/window.c b/src/window.c index 65f441b..5cdc588 100644 --- a/src/window.c +++ b/src/window.c @@ -123,7 +123,7 @@ event(const sapp_event *ev) thg->mouse = (th_vf2){.x = ev->mouse_x, .y = ev->mouse_y}; break; case SAPP_EVENTTYPE_CHAR: - if (ev->char_code < ' ') + if (ev->char_code < ' ' || ev->char_code == 127 /* DEL character */) break; thg->input_string_len = th_utf8_encode(thg->input_string, ev->char_code);