Skip Menu |

This queue is for tickets about the YAML-Syck CPAN distribution.

Report information
The Basics
Id: 18021
Status: resolved
Priority: 0/
Queue: YAML-Syck

People
Owner: Nobody in particular
Requestors: CRAKRJACK [...] cpan.org
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: (no value)
Fixed in: (no value)



Subject: JSON::Syck can create syntax errors in hashes
If a hash has an "implicit" undef value, that value can be completely omitted by JSON, causing a JavaScript syntax error. To repo: perl -MJSON::Syck=Dump -e 'print Dump({foo => !1})' produces: {"foo":} Expected output: {"foo": null}
CC: "Audrey Tang" <autrijus [...] autrijus.org>
Subject: Re: [rt.cpan.org #18021] JSON::Syck can create syntax errors in hashes
Date: Mon, 6 Mar 2006 16:26:24 -0800
To: bug-JSON-Syck [...] rt.cpan.org
From: "Tatsuhiko Miyagawa" <miyagawa [...] gmail.com>
It's strange that your script gives me {"foo":""} at t/04_null.t line 7. but definitely, using undef returns empty string: use JSON::Syck; my $dat = JSON::Syck::Dump({ foo => undef }); like $dat, qr/null/; 1..1 not ok 1 # Failed test in t/04_null.t at line 7. # '{"foo":}' # doesn't match '(?-xism:null)' # Looks like you failed 1 test of 1. On 3/6/06, via RT <bug-JSON-Syck@rt.cpan.org> wrote: Show quoted text
> > Mon Mar 06 19:06:40 2006: Request 18021 was acted upon. > Transaction: Ticket created by CRAKRJACK > Queue: JSON-Syck > Subject: JSON::Syck can create syntax errors in hashes > Owner: Nobody > Requestors: CRAKRJACK@cpan.org > Status: new > Ticket <URL: http://rt.cpan.org/Ticket/Display.html?id=18021 > > > > If a hash has an "implicit" undef value, that value can be completely > omitted by JSON, causing a JavaScript syntax error. > > To repo: > > perl -MJSON::Syck=Dump -e 'print Dump({foo => !1})' > > produces: > {"foo":} > > Expected output: > {"foo": null} > > >
-- Tatsuhiko Miyagawa
On Mon Mar 06 19:26:43 2006, miyagawa@gmail.com wrote: Show quoted text
> It's strange that your script gives me > > {"foo":""} at t/04_null.t line 7. > > but definitely, using undef returns empty string: > > use JSON::Syck; > my $dat = JSON::Syck::Dump({ foo => undef }); > like $dat, qr/null/;
Bizzare; i'm the other way around! : use JSON::Syck; my $dat = JSON::Syck::Dump({ foo => undef }); print "undef == $dat\n"; $dat = JSON::Syck::Dump({ foo => !1 }); print "implicit undef == $dat\n"; Results: undef == {"foo":null} implicit undef == {"foo":} That's with 0.07. Could it be something different about the way libsyck is compiled on our systems?
Subject: Re: [rt.cpan.org #18021] JSON::Syck can create syntax errors in hashes
Date: Mon, 6 Mar 2006 16:35:50 -0800
To: bug-JSON-Syck [...] rt.cpan.org
From: "Tatsuhiko Miyagawa" <miyagawa [...] gmail.com>
On 3/6/06, via RT <bug-JSON-Syck@rt.cpan.org> wrote: Show quoted text
> Bizzare; i'm the other way around! :
Werid. Show quoted text
> use JSON::Syck; > my $dat = JSON::Syck::Dump({ foo => undef }); > print "undef == $dat\n"; > $dat = JSON::Syck::Dump({ foo => !1 }); > print "implicit undef == $dat\n"; > > Results: > undef == {"foo":null} > implicit undef == {"foo":} > > That's with 0.07. > > Could it be something different about the way libsyck is compiled on our > systems?
JSON::Syck and YAML::Syck doesn't use external libsyck, but statically compiles it. -- Tatsuhiko Miyagawa
Show quoted text
> > Could it be something different about the way libsyck is compiled on our > > systems?
> JSON::Syck and YAML::Syck doesn't use external libsyck, but statically > compiles it.
I was thinking more perl's compiler flags, or something else to do with the architecture. I've attached relevant data (perl -V, ldd/nm on Syck.so) in case it's a help.
linux-gate.so.1 => (0xffffe000) libc.so.6 => /lib/tls/libc.so.6 (0xb7de7000) /lib/ld-linux.so.2 (0x80000000)
U abort@@GLIBC_2.0 00007750 T apply_seq_in_map U __assert_fail@@GLIBC_2.0 00017540 d b64_table 00017660 b b64_xtable.3007 00011960 T boot_JSON__Syck 0001762c A __bss_start 0000f150 T bytestring_alloc 0000f1b0 T bytestring_append 0000f350 T bytestring_extend 00003d20 t call_gmon_start U calloc@@GLIBC_2.0 00017640 b completed.4463 00017004 d __CTOR_END__ 00017000 d __CTOR_LIST__ U __ctype_b_loc@@GLIBC_2.3 w __cxa_finalize@@GLIBC_2.1.3 0000bd10 t delete_never 000128f0 t __do_global_ctors_aux 00003d50 t __do_global_dtors_aux 00017520 d __dso_handle 0001700c d __DTOR_END__ 00017008 d __DTOR_LIST__ 00010600 T Dump 000170f4 a _DYNAMIC 0000bf40 T eat_comments 0001762c A _edata 00017a68 A _end 0000c0a0 T escape_seq U fflush@@GLIBC_2.0 00012934 T _fini 00017584 d first.3006 U fprintf@@GLIBC_2.0 U fputc@@GLIBC_2.0 00003db0 t frame_dummy 00016770 r __FRAME_END__ U fread@@GLIBC_2.0 0000ad10 T free_any_io U free@@GLIBC_2.0 U fwrite@@GLIBC_2.0 00003df0 T get_inline 0001720c a _GLOBAL_OFFSET_TABLE_ w __gmon_start__ 00012af0 R hex_table 00003de5 t __i686.get_pc_thunk.bx 0000f14a t __i686.get_pc_thunk.cx 000030e4 T _init 0000c070 T is_newline 00017010 d __JCR_END__ 00017010 d __JCR_LIST__ 00017624 D json_quote_char 00017628 d json_quote_style w _Jv_RegisterClasses 00008d91 t .L10 00008222 t .L100 000081da t .L101 000083d4 t .L106 000083a9 t .L107 0000820e t .L108 00008cf0 t .L11 000083fe t .L110 0000840e t .L111 00008438 t .L112 00008302 t .L114 000082ab t .L117 000080ed t .L118 000082c5 t .L119 00008d05 t .L12 000080c4 t .L120 00007aa3 t .L123 0000832e t .L124 000081c6 t .L125 0000823d t .L126 000081b2 t .L127 00008478 t .L128 00008346 t .L129 00008d1b t .L13 0000854a t .L130 00008df2 t .L14 00009424 t .L145 0000942a t .L146 00008c63 t .L15 0000c1d6 t .L150 0000c220 t .L151 0000c5d4 t .L152 0000c62c t .L153 0000c603 t .L154 0000c550 t .L155 0000c476 t .L156 0000c462 t .L157 0000c440 t .L158 0000c403 t .L159 00008e25 t .L16 0000c3e1 t .L160 0000c395 t .L161 0000962e t .L162 0000c316 t .L162 00009474 t .L163 0000c26c t .L163 0000c2e0 t .L164 0000c24f t .L165 0000c291 t .L166 00008ca3 t .L17 00008ffa t .L173 00008fdc t .L174 00008b90 t .L18 0000c1dd t .L189 00008d42 t .L19 00008d5e t .L20 00004095 t .L206 0000c7ee t .L209 00008e4b t .L21 0000c81e t .L211 00008e58 t .L22 00009645 t .L220 00008ed6 t .L221 0000c8b4 t .L222 0000cc3b t .L223 0000cc97 t .L225 00008e94 t .L226 0000cc4e t .L238 0000ccd6 t .L250 0000cd10 t .L258 000098e0 t .L281 00009907 t .L282 0000992a t .L283 0000995e t .L284 00009944 t .L285 00009a76 t .L287 00009b77 t .L288 000099c0 t .L290 0000997c t .L291 00009b20 t .L292 00009980 t .L295 00009997 t .L296 00008b80 t .L3 00003fd0 t .L327 00009cf3 t .L342 00009cf9 t .L343 00009d46 t .L376 00009d61 t .L377 00009dfb t .L378 00009b46 t .L379 00009b80 t .L380 00008bb8 t .L4 000067a3 t .L403 0000681d t .L404 00006965 t .L405 00009b5c t .L405 00006944 t .L406 00009d77 t .L406 00006923 t .L407 000068d5 t .L408 000069a7 t .L409 00006986 t .L410 000069c8 t .L411 000068b4 t .L412 00006880 t .L413 0000685f t .L414 0000683e t .L415 00008e6b t .L46 00008de7 t .L48 00008fd3 t .L49 00006da9 t .L492 00006dd4 t .L493 00006d76 t .L494 00006d4a t .L495 00006bd8 t .L496 00008bc0 t .L5 0000c0d0 t .L52 000070d8 t .L526 00007031 t .L527 0000c500 t .L527 000071d1 t .L528 00007207 t .L529 0000c0d4 t .L53 00007160 t .L530 0000ea42 t .L534 0000ea8a t .L535 0000c110 t .L54 0000e9e9 t .L546 0000eac0 t .L549 0000c107 t .L55 0000eb1b t .L554 000040f9 t .L56 00008f09 t .L56 0000c0fe t .L56 000040e8 t .L57 0000c0f5 t .L57 000070b0 t .L572 000041a9 t .L58 0000c0ec t .L58 0000c76c t .L588 00004225 t .L59 0000c0e3 t .L59 0000cf3c t .L591 0000cf8d t .L592 0000cfc6 t .L594 0000cfef t .L595 00008b2d t .L6 000042af t .L60 0000c0c5 t .L60 0000d0d7 t .L600 00003fd2 t .L61 0000c0da t .L61 00004357 t .L62 0000c995 t .L624 0000c9e8 t .L625 0000caa8 t .L626 0000cb29 t .L627 0000cb55 t .L628 0000cb87 t .L629 000043f8 t .L63 00004464 t .L64 00004140 t .L65 00004000 t .L68 00008c10 t .L7 0001014f t .L73 000100b8 t .L74 00007adc t .L76 000101b1 t .L76 000084e4 t .L77 0001005d t .L77 000085a8 t .L78 0000c6ed t .L78 000083ef t .L79 0000cd46 t .L79 00008db0 t .L8 0000ce2d t .L80 0000c7e8 t .L805 0000c818 t .L806 0000c8ae t .L807 0000cc35 t .L808 0000cc70 t .L809 0000cd7d t .L81 0000cc91 t .L810 0000cdfb t .L82 0000ce65 t .L83 0000e9bc t .L834 0000e9d4 t .L835 0000ea07 t .L836 0000ce82 t .L84 00008505 t .L85 0000cead t .L85 00008285 t .L87 00008d75 t .L9 0000cc76 t .L902 000082d9 t .L92 000084c2 t .L94 00008488 t .L95 00008387 t .L99 U malloc@@GLIBC_2.0 U memcpy@@GLIBC_2.0 U memmove@@GLIBC_2.0 U memset@@GLIBC_2.0 0000c030 T newline_len 0000b3e0 t new_size 0000bea0 t numcmp 0000bec0 t numhash 00017524 d p.4462 U Perl_av_fetch U Perl_av_len U Perl_av_push U Perl_av_shift U Perl_av_store U Perl_croak U Perl_croak_nocontext U Perl_form U Perl_form_nocontext U Perl_free_tmps U Perl_get_sv U Perl_grok_hex U Perl_grok_number U Perl_grok_oct U Perl_Gthr_key_ptr U Perl_gv_fetchpv U Perl_hv_fetch_ent U Perl_hv_iterinit U Perl_hv_iterkeysv U Perl_hv_iternext U Perl_hv_iternext_flags U Perl_hv_iterval U Perl_hv_store_ent U Perl_is_utf8_string U Perl_Isv_no_ptr U Perl_Isv_undef_ptr U Perl_Isv_yes_ptr 0000fc30 T perl_json_postprocess U Perl_mg_get U Perl_newAV U Perl_newHV U Perl_newRV U Perl_newRV_noinc U Perl_newSV U Perl_newSVnv U Perl_newSVpvn U Perl_newSVpvn_share U Perl_newSVsv U Perl_newSVuv U Perl_newXS U Perl_pop_scope U Perl_push_scope U Perl_safesysfree U Perl_safesysmalloc U Perl_save_int U Perl_sortsv U Perl_sv_2bool U Perl_sv_2mortal U Perl_sv_2pv_flags U Perl_sv_catpvn_flags U Perl_sv_cmp U Perl_sv_len 0000fb90 T perl_syck_bad_anchor_handler 0000fda0 T perl_syck_emitter_handler 0000fbe0 T perl_syck_error_handler 0000f990 T perl_syck_lookup_sym 0000f9f0 T perl_syck_mark_emitter 0000fd40 T perl_syck_output_handler 00011e00 T perl_syck_parser_handler U Perl_Tmarkstack_ptr_ptr U Perl_Tstack_base_ptr U Perl_Tstack_sp_ptr U Perl_Ttmps_floor_ptr U Perl_Ttmps_ix_ptr 000164a7 r __PRETTY_FUNCTION__.2603 000164b9 r __PRETTY_FUNCTION__.2649 000164cb r __PRETTY_FUNCTION__.2713 000175a0 d primes U printf@@GLIBC_2.0 U pthread_getspecific U realloc@@GLIBC_2.0 0000b700 t rehash U sprintf@@GLIBC_2.0 0000b920 T st_add_direct 0000be10 T st_cleanup_safe 0000b9b0 T st_copy 0000bb00 T st_delete 0000bc60 T st_delete_safe U stderr@@GLIBC_2.0 0000bd30 T st_foreach 0000b590 T st_free_table 0000b4d0 T st_init_numtable 0000b500 T st_init_numtable_with_size 0000b530 T st_init_strtable 0000b560 T st_init_strtable_with_size 0000b4a0 T st_init_table 0000b430 T st_init_table_with_size 0000b7d0 T st_insert 0000b630 T st_lookup U strcat@@GLIBC_2.0 U strchr@@GLIBC_2.0 U strcmp@@GLIBC_2.0 0000be60 t strhash U strlen@@GLIBC_2.0 U strncat@@GLIBC_2.0 U strtod@@GLIBC_2.0 U __strtod_internal@@GLIBC_2.0 U strtol@@GLIBC_2.0 U __strtol_internal@@GLIBC_2.0 0000a9f0 T syck_add_sym 00008980 T syck_add_transfer 00009fc0 T syck_alloc_map 00009e20 T syck_alloc_node 0000a030 T syck_alloc_seq 0000a0a0 T syck_alloc_str 0000a750 T syck_assert 00004ea0 T syck_base64dec 00004c90 T syck_base64enc 0000b170 T syck_check_limit 00017a64 B syckdebug 0000b390 T syck_default_error_handler 00005690 T syck_emit 000060b0 T syck_emit_1quoted 00006740 T syck_emit_2quoted 00007320 T syck_emit_end 00006280 T syck_emit_folded 00005c60 T syck_emit_indent 00006ff0 T syck_emit_item 00006470 T syck_emit_literal 00006f40 T syck_emit_map 00006a20 T syck_emit_scalar 00006e90 T syck_emit_seq 000059a0 T syck_emit_tag 00005340 T syck_emitter_add_level 000054b0 T syck_emitter_clear 00005120 T syck_emitter_current_level 000065d0 T syck_emitter_escape 00005540 T syck_emitter_flush 00005410 T syck_emitter_handler 00007480 T syck_emitter_mark_node 00005140 T syck_emitter_parent_level 00005160 T syck_emitter_pop_level 000051a0 T syck_emitter_reset_levels 000050a0 T syck_emitter_st_free 000055a0 T syck_emitter_write 0000bed0 T syckerror 00005430 T syck_free_emitter 00009e70 T syck_free_members 00009f60 T syck_free_node 0000ad60 T syck_free_parser 00008710 T syck_hdlr_add_anchor 00008690 T syck_hdlr_add_node 00008880 T syck_hdlr_get_anchor 000087f0 T syck_hdlr_remove_anchor 0000a810 T syck_io_file_read 0000a870 T syck_io_str_read 0000f0a0 T sycklex 00003f10 T sycklex_bytecode_utf8 0000c120 T sycklex_yaml_utf8 0000aa70 T syck_lookup_sym 0000a3d0 T syck_map_add 0000a590 T syck_map_assign 0000a580 T syck_map_count 0000a350 T syck_map_empty 0000a5c0 T syck_map_read 0000a4a0 T syck_map_update 00008b00 T syck_match_implicit 0000b0d0 T syck_move_tokens 00005250 T syck_new_emitter 0000a460 T syck_new_map 0000ac60 T syck_new_parser 0000a660 T syck_new_seq 0000a180 T syck_new_str 0000a100 T syck_new_str2 00005420 T syck_output_handler 000077c0 T syckparse 0000b350 T syck_parse 0000b000 T syck_parser_add_level 0000ae60 T syck_parser_bad_anchor_handler 0000afe0 T syck_parser_current_level 0000ae50 T syck_parser_error_handler 0000ae80 T syck_parser_file 0000ae00 T syck_parser_handler 0000ae10 T syck_parser_implicit_typing 0000ab70 T syck_parser_pop_level 00017a60 B syck_parser_ptr 0000b1b0 T syck_parser_read 0000b280 T syck_parser_readlen 0000a920 T syck_parser_reset_cursor 0000abb0 T syck_parser_reset_levels 0000ae70 T syck_parser_set_input_type 0000a9e0 T syck_parser_set_root_on_error 0000af00 T syck_parser_str 0000af90 T syck_parser_str_auto 0000ae30 T syck_parser_taguri_expansion 0000a270 T syck_replace_str 0000a1c0 T syck_replace_str2 00005d00 T syck_scan_scalar 0000a5f0 T syck_seq_add 0000a710 T syck_seq_assign 0000a700 T syck_seq_count 0000a6a0 T syck_seq_empty 0000a730 T syck_seq_read 0000aae0 T syck_st_free 00005070 T syck_st_free_anchors 0000aab0 T syck_st_free_nodes 0000a2c0 T syck_str_blow_away_commas 0000a7b0 T syck_strndup 0000a340 T syck_str_read 00009760 T syck_tagcmp 00008a60 T syck_taguri 00008af0 T syck_try_implicit 00009850 T syck_type_id_to_uri 0000f140 T syckwrap 000089f0 T syck_xprivate 0000f890 T syck_yaml2byte 0000f520 T syck_yaml2byte_handler 00009690 T try_tag_implicit 0001761c d type_numhash 00017614 d type_strhash 000117c0 T XS_JSON__Syck_Dump 00010e30 T XS_JSON__Syck_Load 00013160 r yycheck 00012f40 r yydefact 00012e40 r yydefgoto 00007740 t yydestruct 00013420 r yypact 00012e5d r yypgoto 00013620 r yyprhs 00012e80 r yyr1 00012ee0 r yyr2 00013520 r yyrhs 00013680 r yyrline 000075f0 t yy_stack_print 00012dc0 r yystos 000076b0 t yysymprint 00012fc0 r yytable 00017020 d yytname 00013300 r yytranslate
Summary of my perl5 (revision 5 version 8 subversion 8) configuration: Platform: osname=linux, osvers=2.6.15, archname=i486-linux-gnu-thread-multi uname='linux ninsei 2.6.15 #1 smp preempt sat jan 7 12:47:52 pst 2006 i686 gnulinux ' config_args='-Dusethreads -Duselargefiles -Dccflags=-DDEBIAN -Dcccdlflags=-fPIC -Darchname=i486-linux-gnu -Dprefix=/usr -Dprivlib=/usr/share/perl/5.8 -Darchlib=/usr/lib/perl/5.8 -Dvendorprefix=/usr -Dvendorlib=/usr/share/perl5 -Dvendorarch=/usr/lib/perl5 -Dsiteprefix=/usr/local -Dsitelib=/usr/local/share/perl/5.8.8 -Dsitearch=/usr/local/lib/perl/5.8.8 -Dman1dir=/usr/share/man/man1 -Dman3dir=/usr/share/man/man3 -Dsiteman1dir=/usr/local/man/man1 -Dsiteman3dir=/usr/local/man/man3 -Dman1ext=1 -Dman3ext=3perl -Dpager=/usr/bin/sensible-pager -Uafs -Ud_csh -Uusesfio -Uusenm -Duseshrplib -Dlibperl=libperl.so.5.8.8 -Dd_dosuid -des' hint=recommended, useposix=true, d_sigaction=define usethreads=define use5005threads=undef useithreads=define usemultiplicity=define useperlio=define d_sfio=undef uselargefiles=define usesocks=undef use64bitint=undef use64bitall=undef uselongdouble=undef usemymalloc=n, bincompat5005=undef Compiler: cc='cc', ccflags ='-D_REENTRANT -D_GNU_SOURCE -DTHREADS_HAVE_PIDS -DDEBIAN -fno-strict-aliasing -pipe -Wdeclaration-after-statement -I/usr/local/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64', optimize='-O2', cppflags='-D_REENTRANT -D_GNU_SOURCE -DTHREADS_HAVE_PIDS -DDEBIAN -fno-strict-aliasing -pipe -Wdeclaration-after-statement -I/usr/local/include' ccversion='', gccversion='4.0.3 20060128 (prerelease) (Debian 4.0.2-8)', gccosandvers='' intsize=4, longsize=4, ptrsize=4, doublesize=8, byteorder=1234 d_longlong=define, longlongsize=8, d_longdbl=define, longdblsize=12 ivtype='long', ivsize=4, nvtype='double', nvsize=8, Off_t='off_t', lseeksize=8 alignbytes=4, prototype=define Linker and Libraries: ld='cc', ldflags =' -L/usr/local/lib' libpth=/usr/local/lib /lib /usr/lib libs=-lgdbm -lgdbm_compat -ldb -ldl -lm -lpthread -lc -lcrypt perllibs=-ldl -lm -lpthread -lc -lcrypt libc=/lib/libc-2.3.5.so, so=so, useshrplib=true, libperl=libperl.so.5.8.8 gnulibc_version='2.3.5' Dynamic Linking: dlsrc=dl_dlopen.xs, dlext=so, d_dlsymun=undef, ccdlflags='-Wl,-E' cccdlflags='-fPIC', lddlflags='-shared -L/usr/local/lib' Characteristics of this binary (from libperl): Compile-time options: MULTIPLICITY PERL_IMPLICIT_CONTEXT PERL_MALLOC_WRAP THREADS_HAVE_PIDS USE_ITHREADS USE_LARGE_FILES USE_PERLIO USE_REENTRANT_API Built under linux Compiled at Feb 9 2006 22:12:59 %ENV: PERL5LIB="/home/faraway/perl5lib/i386-linux-thread-multi:/home/faraway/perl5lib" @INC: /home/faraway/perl5lib/i386-linux-thread-multi /home/faraway/perl5lib /etc/perl /usr/local/lib/perl/5.8.8 /usr/local/share/perl/5.8.8 /usr/lib/perl5 /usr/share/perl5 /usr/lib/perl/5.8 /usr/share/perl/5.8 /usr/local/lib/site_perl /usr/local/lib/perl/5.8.7 /usr/local/share/perl/5.8.7 /usr/local/lib/perl/5.8.4 /usr/local/share/perl/5.8.4 .
RT-Send-CC: autrijus [...] autrijus.org, miyagawa [...] gmail.com
Right now, I get the following if I run the previously mentioned one liners: $>perl -MJSON::Syck=Dump -E 'say Dump({foo => undef})' {"foo":null} $>perl -MJSON::Syck=Dump -E 'say Dump({foo => !1})' {"foo":""} As I see it, this is doing the right thing since !1 translates to an empty string in perl, which is false. You're kind of hitting the limits of perl's ability to talk with JSON. I've been down this road dealing with quoted versus unquoted numbers in recent versions of JSON::Syck. Do we need to do something further as of the most recent version of JSON::Syck? If so, please re-open the ticket so we can discuss further. Thanks, Todd