dor send --stdin interprets backslash escapes in piped bytes
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 3/5
- Tempo stimato
- 1-2 giorni
- Idoneità per principianti
- 50/100
- Tipo di issue
- Bug
- Chiarezza
- Abbastanza chiara
- Stato di attività
- Tranquilla
- Stack tecnologico
- typescript
- Ambito
- cli
Direzione di ricerca
Inizia in dor/src/commands/send.ts, nella gestione di stdin e nella conversione degli escape del testo descritte nell’issue. Conferma il comportamento attuale con l’esempio documentato di piping, quindi attendi che il maintainer scelga tra raw stdin come impostazione predefinita e la documentazione del comportamento esistente. Il lavoro è concluso quando il contratto scelto è implementato o documentato, con un test di regressione che preservi i byte rilevanti.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
dor send --stdin interprets backslash escapes in piped bytes, corrupting the documented use case
dor send --stdin reads standard input and forwards it as a text input:
if (flags.stdin === true) {
if (!readStdin) return { ok: false, message: 'stdin is not available' };
return { ok: true, value: [{ kind: 'text', text: await readStdin() }] };
}
Text inputs then run through interpretTextEscapes unless --raw is set:
input += raw ? item.text : interpretTextEscapes(item.text);
(send.ts:227-228, converting \n \r \t \\ at send.ts:238-253)
Why this is a footgun for --stdin
The flagship stdin example in the help is:
cat script.sh | dor send surface:3 --stdin
Bytes arriving on stdin are already literal — they are not a shell-authored string where a two-character \t stands in for a tab. Shell scripts routinely contain literal backslash sequences (printf 'a\tb', sed 's/\n/ /', grep -P '\d', Windows paths with \\). Piping such a file through --stdin silently rewrites every \n/\r/\t/\\, so the text typed into the target terminal is not the file's contents.
Repro: printf 'printf "a\\tb\\n"\n' | dor send surface:3 --stdin types a real TAB and newline into the middle of the line instead of the literal \t/\n the script source contains.
The escape interpretation is desirable for --text "echo hi\nthere" (a human types escapes on the command line), but for --stdin the input is already-real bytes.
Design question (why an issue, not a drive-by PR)
The current behavior is consistent with the documented contract — the help says "Text input interprets backslash escapes … unless --raw is set" (send.ts:97), and --stdin is documented as text input — so flipping the default is a contract change that needs a maintainer call. Options:
- Make
--stdinraw by default — treat piped bytes as literal; keep--textinterpreting escapes. Most aligned with thecat script.sh | …example. Would need an opt-in flag if anyone wants escape interpretation on stdin. - Keep current behavior, document it — call out at the
--stdinhelp that it interprets escapes and that--rawis needed for literal file contents.
I lean toward option 1, but it changes documented behavior, so I'm leaving the call to a maintainer. Happy to open the PR (including a regression test that pipes a script containing \t and asserts the bytes are preserved) once a direction is chosen.
Surfaced by the nightly code-quality survey.
- Lingua principale
- TypeScript
- Stelle
- 5
- Fork
- 1
- Merge medio
- 18h 26m
- PR unite (30g)
- 229
Guida per i contributori
Nessuna guida per i contributori indicizzata per questo repository
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di diffplug/dormouse
-
Difficoltà 4/5 3-5 giorni Idoneità per principianti 35/100
-
Difficoltà 4/5 3-5 giorni Idoneità per principianti 35/100
-
Difficoltà 4/5 3-5 giorni Idoneità per principianti 25/100
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 45/100
-
Difficoltà 4/5 3-5 giorni Idoneità per principianti 25/100
Tutte le issue di diffplug/dormouse
Issue simili
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 84/100
copse-dev/agent-pane#2953 ·
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 84/100
Eynzof/Hermes-CN-Desktop#610 ·
-
[Bug]: Matrix progress drafts fail with "Matrix runtime not initialized" during tool activity Apertabug clawsweeper:linked-pr-open clawsweeper:needs-live-repro clawsweeper:no-new-fix-pr impact:message-loss issue-rating: 🐚 platinum hermit P2 regression
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
-
enhancement
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
-
calcite-components needs triage refactor
Difficoltà 2/5 1-3 ore Idoneità per principianti 75/100
Esri/calcite-design-system#15203 ·