fix: harden readSecret newline handling and add phpinfo version - #52
Merged
Conversation
- readSecret() now prints a newline to stdout when the user presses Enter, so subsequent output starts on a fresh line (POSIX + Windows) - readSecret() now prints a newline on Ctrl-C/Ctrl-D/Escape abort so the terminal stays clean (POSIX + Windows) - Removed dead partial-write check in readSecret() prompt write path; terminal_stream_write() already loops until completion - Marked terminal_win_stdin_is_raw as volatile for correct compiler behavior under ZTS builds - phpinfo() now displays the extension version - Added tests/025 and tests/026 for the newline behavior
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.
What
Fixes
readSecret()terminal output behavior and adds quality-of-life improvements.readSecret() newline on Enter
readSecret()now prints a newline to stdout when the user presses Enter, so subsequent output starts on a fresh line. Previously the caller's next output would continue on the same line as the***mask. Applies to both POSIX and Windows.readSecret() newline on abort
readSecret()now prints a newline to stdout when the user aborts with Ctrl-C, Ctrl-D, or Escape, so the terminal prompt stays clean before the thrown error. Applies to both POSIX and Windows.Dead code removal
Removed the
written != (zend_long) ZSTR_LEN(prompt)partial-write check in thereadSecret()prompt path —terminal_stream_write()already loops until all bytes are written or returnsfalseon failure, so this check was unreachable.Windows ZTS correctness
Marked
terminal_win_stdin_is_rawasvolatileso the compiler doesn't reorder or cache reads of this process-global flag aroundSetConsoleModecalls in ZTS builds.phpinfo() version
phpinfo()now displays the extension version alongside backend and support status.Tests
tests/025_read_secret_newline.phpt— verifies newline is printed after Entertests/026_read_secret_abort.phpt— verifies newline is printed before the thrown error on Ctrl-C abortVerification
/private/tmpwith-Wall -Wextra: no warningsphp -i | grep terminalconfirms version display