From 555b5f16257fbeb8b6a352f6b9e52492552ee53c Mon Sep 17 00:00:00 2001 From: Nico Passlick Date: Tue, 19 Aug 2025 16:19:19 +0000 Subject: [PATCH] fix: sanitize additional input --- modes/DEFAULT.yaml.example | 1 + pyproject.toml | 2 +- scanner_cli/main.py | 6 +++--- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/modes/DEFAULT.yaml.example b/modes/DEFAULT.yaml.example index 608f0ed..b68ce2d 100644 --- a/modes/DEFAULT.yaml.example +++ b/modes/DEFAULT.yaml.example @@ -21,3 +21,4 @@ strip_prefix: false # ADDITIONAL INPUT enable_input: false +eval_mathops: false diff --git a/pyproject.toml b/pyproject.toml index 7adcc1c..f47ca5b 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta" [project] name = "scanner-cli" -version = "1.0.3" +version = "1.0.4" description = "CLI tool to read barcodes via stdin and route them to REST endpoints based on configurable modes." readme = "README.md" authors = [{ name = "Passlick Development", email = "hello@passlickdev.com" }] diff --git a/scanner_cli/main.py b/scanner_cli/main.py index 4ab645b..5bfd89e 100644 --- a/scanner_cli/main.py +++ b/scanner_cli/main.py @@ -103,7 +103,7 @@ def _eval_mathops(expr: str): _ANSI_CSI_RE = re.compile(r"\x1B\[[0-?]*[ -/]*[@-~]") -def sanitize_barcode(value: str) -> str: +def sanitize_input(value: str) -> str: if not value: return value cleaned = _ANSI_CSI_RE.sub("", value) @@ -230,7 +230,7 @@ def schedule_timeout(): if line == '': log_event("stdin_eof") break - barcode = sanitize_barcode(line.strip()) + barcode = sanitize_input(line.strip()) if not barcode: continue @@ -303,7 +303,7 @@ def schedule_timeout(): evaluated = extra else: evaluated = extra - payload["input"] = evaluated + payload["input"] = sanitize_input(evaluated) payload["action"] = "scan+input" try: