Refactor/code quality improvements#67
Merged
Merged
Conversation
…_port slash, stdout redirect #4 Remove no-op 'global json_headers' declaration from main(); json_headers is a loop-local variable and the global declaration had no effect. #5 Remove misleading 'if' in normalize(): socket.inet_aton() always returns truthy bytes when it doesn't raise, so the condition was never False. #6 Replace runtime .lower() calls on string literals with their lowercase equivalents ('Content-Security-Policy'.lower() -> 'content-security-policy' etc.) in the header-checking loop and frame-ancestors pop. #7 append_port no longer adds a trailing slash when the input URL didn't have one (http://example.com:8080 instead of http://example.com:8080/). #8 Remove the sys.stdout -> devnull redirect under -j: log() already suppresses output when json_output=True, making the redirect redundant. Removing it also eliminates the file handle leak and lets test helpers use a simple patch('sys.stdout') instead of the __stdout__/finally dance. Drop now-unused 'import os'. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- Fix #1: -g now normalises to usemethod='GET' in parse_options so it no longer silently overrides -m; check_target accepts usemethod param - Fix #2: client_headers mutation in main() replaced with a local copy - Fix #3: parse_headers() returns dict instead of writing to global; module-level headers variable removed - Fix #4: darkcolours/lightcolours merged into a single _make_colours() factory (only WARNING differed between the two classes) - Fix #5: parse_options() moved before main() - Fix #6: NoRedirectHandler moved to module level instead of being redefined inside build_opener() on every call - Fix #7: bare try/except Exception: pass around resp.status removed - Fix #8: SSL error message indentation artifact from line continuation fixed - Fix #9: build_opener() called once in main() before the target loop instead of once per target inside check_target() - Fix #10: check_target() no longer reads from global options; options=None added at module level to make the dependency explicit - Fix #11: is_https() inlined at its single call site and removed - Fix #12: trailing whitespace removed - Fix #13: replace optparse with argparse - Fix #14: NoRedirectHandler._handle_redirect docstring updated Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.