Forced single-quoted or literal style emits raw NUL and U+0001
Nessuno ha ancora preso questa issue.
- #1508 di @himanshu748 — chiusa senza merge
Valutazione
- Difficoltà
- 3/5
- Tempo stimato
- 1-2 giorni
- Idoneità per principianti
- 45/100
Direzione di ricerca
The bug is in src/emitterutils.cpp: IsValidSingleQuotedScalar and IsValidLiteralScalar lack a non-printable check (both carry a TODO), so the double-quoted fallback never runs. Read how the emitter picks a style, then reproduce with the snippet in the issue and inspect the bytes with xxd. Done when NUL and U+0001 under SingleQuoted or Literal produce escaped output, and the Auto and DoubleQuoted results are unchanged. Closed PR #1508 was not merged, so check why before starting.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
On master 1e0876c, forcing YAML::SingleQuoted or YAML::Literal on a string containing NUL (U+0000) or U+0001 writes the raw character into the output. Auto and DoubleQuoted escape them correctly.
YAML 1.2.2 section 5.1: "On output, a YAML processor must only produce only characters in this printable subset. Characters outside this set must be presented using escape sequences." NUL and U+0001 are outside that set, and the JSON-compatibility allowance for quoted scalars only covers non-C0 characters. TAB, LF, CR and NEL are allowed and not reported here. PyYAML and a ruamel.yaml loader set to YAML 1.2 both reject the raw output.
The repro uses UTF-8 strings and the default UTF-8 output; the reported NUL/U+0001 are scalar content characters, not zero bytes in UTF-16/UTF-32 encoding.
Repro: emit "a" + c + "b" for c in {0x00, 0x01} with Auto, SingleQuoted, Literal and DoubleQuoted, then inspect with xxd.
#include <yaml-cpp/yaml.h>
#include <fstream>
#include <string>
int main() {
const char values[] = {char(0x00), char(0x01)};
const YAML::EMITTER_MANIP styles[] = {
YAML::Auto, YAML::SingleQuoted, YAML::Literal, YAML::DoubleQuoted
};
const char* names[] = {"auto", "single", "literal", "double"};
for (unsigned i = 0; i < 2; ++i) {
for (unsigned j = 0; j < 4; ++j) {
const std::string s = std::string("a") + values[i] + "b";
const std::string path = std::to_string(i) + "-" + names[j] + ".yaml";
std::ofstream f(path, std::ios::binary);
YAML::Emitter e(f);
e << styles[j] << s;
}
}
}
Cause: IsValidSingleQuotedScalar and IsValidLiteralScalar in src/emitterutils.cpp have no non-printable check (both carry a TODO), so the double-quoted fallback never triggers.
Minor note: U+007F (DEL) is written raw in every style. It's outside c-printable, though the grammar's JSON-compatibility rule admits it inside quoted scalars, and section 5.1 recommends escaping non-printables even there. I'm not claiming quoted DEL is invalid syntax; the raw literal-style case is outside the literal character set. Parsers above also reject it.
I used AI tools to find and reproduce this; I reviewed it myself.
- Lingua principale
- C++
- Stelle
- 6.1k
- Fork
- 2.2k
- Merge medio
- 22h 2m
- PR unite (30g)
- 1
Preparare l'ambiente
- Nessun Dockerfile né file Docker Compose
- Nessun modello di pull request
- Leggi la guida per i contributori
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 jbeder/yaml-cpp
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 82/100
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 82/100
-
Difficoltà 3/5 1-2 giorni Idoneità per principianti 62/100
-
Difficoltà 3/5 Mezza giornata Idoneità per principianti 55/100
-
Difficoltà 3/5 1-2 giorni Idoneità per principianti 62/100
Tutte le issue di jbeder/yaml-cpp
Issue simili
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
eclipse-score/lifecycle#929 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 62/100
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
colbymchenry/codegraph#3223 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 75/100
firefox-devtools/profiler#6436 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
The `ufw` decoder requires the kernel's monotonic timestamp, so UFW lines read from journald decode without any fieldForse già presa Una pull request collegata a questa issue è aperta o già unita. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
I maintainer di solito rispondono entro 1 giorno