cli: --path-encoding=raw|escape for safe plain output (#45 part 1) - #194
Merged
Conversation
The plain renderer can now C-escape path bytes so a newline or control character in a filename cannot corrupt the line-oriented -print stream: --path-encoding=escape turns `\` and control bytes into `\\`, `\n`, `\t`, `\r`, or `\xNN`; raw (the default) stays verbatim and find-compatible. It applies to the plain format only -- kNul keeps raw bytes (the NUL is the separator) and kJsonl always JSON-escapes. render::Renderer gains a PathEncoding; run.cc ResolvePathEncoding mirrors ResolveFormat (last wins, raw default) and feeds the implicit-print renderer. Self-documented via the globals table + kHelpText (so --help/--man/--markdown list it). render_test covers escape/raw and that it applies only to plain. The other half of #45 (--exact, filesystem-native matching) remains.
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.
First half of #45. The plain renderer can C-escape path bytes so a newline / control char in a filename can't corrupt the line-oriented
-printstream:--path-encoding=escape->\\,\n,\t,\r, else\xNN;raw(default) is verbatim + find-compatible.kNulstays raw (NUL is the separator),kJsonlalways JSON-escapes.render::Renderergains aPathEncoding;run.ccResolvePathEncodingmirrorsResolveFormat. Self-documented via the globals table +kHelpText(flows to--help/--man/--markdown).render_testcovers escape/raw + plain-only.Verified: 13 cli/render/run tests green;
--path-encoding=escapeend-to-end turned a tab in a filename into\t. The--exact(FS-native matching) half of #45 is next.