commit 6e396ee617e4b06b01ff40372b6321674d798f5b
parent e1a2bbec2d3779a32d5f399242ed797fb1491dc3
Author: ASWANTH R <aswanthr82@gmail.com>
Date: Mon, 19 Oct 2026 17:24:25 +0530
Implement HTML escape function
Added escape function to safely escape HTML characters.
Diffstat:
1 file changed, 5 insertions(+), 0 deletions(-)
diff --git a/pytml.js b/pytml.js
@@ -160,6 +160,8 @@ fetch('https://pytml.vercel.app/api/count', {
import js
import asyncio
from pyodide.ffi import create_proxy
+import html as _html_escape
+
_callbacks = []
@@ -355,6 +357,9 @@ def gamepads(): return js.pytmlInstance.gamepads()
def storage_get(key, fallback=None): return js.pytmlInstance.storage_get(key, fallback)
def storage_set(key, value): return js.pytmlInstance.storage_set(key, value)
def storage_remove(key): return js.pytmlInstance.storage_remove(key)
+def escape(text):
+ """Safely escape HTML characters (<, >, &) from user input."""
+ return _html_escape.escape(str(text))
def install(requirements, **kwargs):
import micropip
return micropip.install(requirements, **kwargs)