mirror of
https://github.com/hansjone/netx.git
synced 2026-10-12 16:30:47 +08:00
Skip WebCRT audit for empty Enter on prompt-only lines.
Do not reuse the previous command when the operator presses Enter on a blank prompt; validate prompt-only rows on both frontend and backend. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
parent
b35e56afb0
commit
7ca57278fe
4 changed files with 109 additions and 21 deletions
|
|
@ -539,6 +539,34 @@ def _is_prompt_command_line(line: str) -> bool:
|
|||
)
|
||||
|
||||
|
||||
def is_auditable_command_line(line: str) -> bool:
|
||||
"""False for empty Enter (prompt only, no command text)."""
|
||||
s = normalize_audit_line(line)
|
||||
if not s.strip():
|
||||
return False
|
||||
if _is_prompt_only_line(s):
|
||||
return False
|
||||
return True
|
||||
|
||||
|
||||
def _is_prompt_only_line(line: str) -> bool:
|
||||
"""True when line is a device prompt with no command typed."""
|
||||
s = normalize_audit_line(line)
|
||||
if not s:
|
||||
return True
|
||||
return bool(
|
||||
re.match(
|
||||
r"^(?:"
|
||||
r"[\w.-]+(?:\([^)]+\))*[#>]\s*"
|
||||
r"|<[^>]+>\s*"
|
||||
r"|\[[^\]]+\]\s*"
|
||||
r")$",
|
||||
s,
|
||||
flags=re.I,
|
||||
)
|
||||
)
|
||||
|
||||
|
||||
def extract_last_prompt_command(text: str) -> str | None:
|
||||
"""Last prompt+command line in PTY transcript (tab-complete redraw aware).
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue