Skip to content

Fix download-menu input revalidation - #213

Open
dajiaohuang wants to merge 3 commits into
Mebus:masterfrom
dajiaohuang:fix/python-bugs-encoding-validation
Open

dajiaohuang wants to merge 3 commits into
Mebus:masterfrom
dajiaohuang:fix/python-bugs-encoding-validation

Conversation

@dajiaohuang

@dajiaohuang dajiaohuang commented Oct 7, 2026 •

Copy link
Copy Markdown

Summary

Narrow this contribution to the actual download-menu validation bug. The original separate digit/range loops can accept an out-of-range number, reprompt with text, and then raise ValueError. Validate every response in one loop against the displayed 1–38 choices. Use isdecimal rather than isdigit so Unicode digit characters that int() cannot parse are rejected; surrounding menu whitespace is accepted.

Removed the unrelated encoding-policy, profile-input stripping, duplicate-word concatenation, output formatting, resource/counting and dead-code changes from the original PR. Their necessity and compatibility were not established for this focused fix. Password-generation behavior remains the original baseline.

Validation

python tests/test_download_choice.py: 3 tests pass. They exercise the real menu function with controlled input/config and a mocked download boundary; no dictionaries are downloaded and no target activity is performed. The previous PR head fails the nondecimal-digit case. git diff --check passes.

Codacy reports an unresolved gate. Its detailed annotation was not exposed by the current GitHub result; this change does not claim to resolve that report or to pass the full CI suite. No dependency installation or live download acceptance claimed.

…lity

- Add explicit UTF-8 encoding to all file I/O operations (fixes Unicode issues)
- Add .strip() to all interactive user inputs to handle trailing whitespace
- Fix list.index() bug in improve_dictionary using enumerate() for correct dedup
- Use context managers (with statement) for proper file handling
- Fix hyperspeed print: strip trailing newlines to avoid double-spacing
- Use os.name for cross-platform clear command (cls on Windows, clear on Unix)
- Fix time.sleep(0000.1) unusual octal literal to clean 0.1
- Remove unreachable dead code after sys.exit()
- Fix download_wordlist validation loop (ignored isdigit() return, invalid re-prompt)
- Use sum(1 for _ in f) for cleaner line counting
@codacy-production

codacy-production Bot commented Oct 7, 2026 •

Copy link
Copy Markdown

Up to standards ✅

🟢 Issues 0 issues

Results:
0 new issues

View in Codacy

🟢 Metrics 4 complexity

Metric Results
Complexity 4

View in Codacy

NEW Get contextual insights on your PRs based on Codacy's metrics, along with PR and Jira context, without leaving GitHub. Enable AI reviewer
TIP This summary will be updated as you push new changes.

@dajiaohuang dajiaohuang changed the title Fix Python bugs: encoding, input validation, cross-platform compatibility Oct 15, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

1 participant