Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dump() can create invalid YAML 1.1 #17

Closed
perlpunk opened this issue May 24, 2019 · 1 comment
Closed

Dump() can create invalid YAML 1.1 #17

perlpunk opened this issue May 24, 2019 · 1 comment

Comments

@perlpunk
Copy link
Owner

perlpunk commented May 24, 2019

For certain strings YAML::Dump() creates YAML with control characters not escaped. it is valid YAML 1.2, but not YAML 1.1:

use Encode;
use Devel::Peek;
use YAML::PP;
use YAML::XS ();            
my $binary = "\342\202\254";   
my $dump = YAML::PP::Dump($binary);
Dump $dump;                      
my $encoded = encode_utf8($dump);
Dump $encoded;            
YAML::XS::Load($encoded);

__END__

SV = PV(0x56201c459070) at 0x56201c478358
  REFCNT = 1
  FLAGS = (POK,IsCOW,pPOK,UTF8)
  PV = 0x56201ca49e80 "--- '\303\242\302\202\302\254'\n"\0 [UTF8 "--- '\x{e2}\x{82}\x{ac}'\n"]
  CUR = 13
  LEN = 16
  COW_REFCNT = 0
SV = PV(0x56201c99c0e0) at 0x56201ca54c38
  REFCNT = 1
  FLAGS = (POK,IsCOW,pPOK)
  PV = 0x56201ca49e80 "--- '\303\242\302\202\302\254'\n"\0
  CUR = 13
  LEN = 16
  COW_REFCNT = 1
YAML::XS::Load Error: The problem:

    control characters are not allowed

was found at document: 0

https://yaml.org/spec/1.1/

[128]	nb-double-char	::=	( nb-char - “\” - “"” ) | ns-esc-char	
[34]	nb-char	::=	c-printable - b-char

https://yaml.org/spec/1.2/spec.html

[107]	nb-double-char	::=	c-ns-esc-char | ( nb-json - “\” - “"” )
[2]	nb-json	::=	#x9 | [#x20-#x10FFFF]

See also ingydotnet/yaml-pm#217

perlpunk added a commit that referenced this issue Jan 28, 2020
See
* #17 dump_string must not care about Perl's internal representation of a variable
* #18 Dump() can create invalid YAML 1.1
perlpunk added a commit that referenced this issue Jan 28, 2020
See
* #16 dump_string must not care about Perl's internal representation of a variable
* #17 Dump() can create invalid YAML 1.1
perlpunk added a commit that referenced this issue Jan 30, 2020
See
* #16 dump_string must not care about Perl's internal representation of a variable
* #17 Dump() can create invalid YAML 1.1
@perlpunk
Copy link
Owner Author

Will be fixed in v0.019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant