Skip to content

The agent that grows with you

fix(plugins): a regex after return is not division

Teknium493208879a32
diff --git a/hermes_cli/plugin_validate_desktop.py b/hermes_cli/plugin_validate_desktop.py
index f09b3fd8290..e57db92ab9f 100644
--- a/hermes_cli/plugin_validate_desktop.py
+++ b/hermes_cli/plugin_validate_desktop.py
@@ -138,7 +138,10 @@ def _slash_readings(source: str, at: int) -> tuple[bool, bool]:
return False, True
if prev in "(,=:[!&|?{;+-*%<>~^":
return True, False
- return bool(_REGEX_AFTER_WORD.search(source, max(0, j - 12), j + 1)), True
+ keyword = _REGEX_AFTER_WORD.search(source, max(0, j - 12), j + 1)
+ if keyword: # an expression must follow ``return`` etc.; ``of`` may also be a plain name
+ return True, source[j - 1:j + 1] == "of"
+ return False, True
def _step(source: str, i: int, state: tuple) -> tuple[bool, list[tuple]]:
diff --git a/tests/hermes_cli/test_plugin_validate.py b/tests/hermes_cli/test_plugin_validate.py
index 0237e461d9f..3f25a32a8bc 100644
--- a/tests/hermes_cli/test_plugin_validate.py
+++ b/tests/hermes_cli/test_plugin_validate.py
@@ -379,6 +379,7 @@ class TestDesktopSurface:
"const m = Number(\"if (\") / (Storage.prototype.setItem = spy, 2) / 3\n"
"if (false) /\"/.test(label); Storage.prototype.setItem = spy; const tail = \"/\"\n"
"function L() {}\nlet v; true ? {L: v} = options : null; L.prototype.isL = 1\n"
+ "function U() {}\nfunction matcher() { return /U = vector/ } U.prototype.isU = 1\n"
))
assert desktop_surface_hits(d) == [
"prototype patching (desktop/plugin.js:5)",