From 6c3cdb04ac1794d2b3fd24f7da4c9ec4aac05d11 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Sat, 28 Jan 2012 22:01:49 -0400 Subject: [PATCH] Switch to YAML::XS to work around insanity in YAML::Mo. Closes: #657533 https://rt.cpan.org/Ticket/Display.html?id=74487 Gave up trying to support multiple YAML backends. The XS one requires ugly manual encoding to get unicode right, and doesn't allow dumping yaml fragments w/o the yaml header, but at least it doesn't randomly crash on import like YAML::Mo has started to. --- Bundle/IkiWiki.pm | 2 +- IkiWiki/Setup/Yaml.pm | 12 +++++------- debian/changelog | 1 + debian/control | 4 ++-- ikiwiki.in | 6 ++---- 5 files changed, 11 insertions(+), 14 deletions(-) diff --git a/Bundle/IkiWiki.pm b/Bundle/IkiWiki.pm index a0bd60e46..005936250 100644 --- a/Bundle/IkiWiki.pm +++ b/Bundle/IkiWiki.pm @@ -28,7 +28,7 @@ CGI::Session Mail::Sendmail CGI Data::Dumper -YAML +YAML::XS JSON RPC::XML diff --git a/IkiWiki/Setup/Yaml.pm b/IkiWiki/Setup/Yaml.pm index 6da93bb64..6bf20f480 100644 --- a/IkiWiki/Setup/Yaml.pm +++ b/IkiWiki/Setup/Yaml.pm @@ -11,10 +11,8 @@ sub loaddump ($$) { my $class=shift; my $content=shift; - eval q{use YAML::Any}; - eval q{use YAML} if $@; + eval q{use YAML::XS}; die $@ if $@; - $YAML::Syck::ImplicitUnicode=1; IkiWiki::Setup::merge(Load(encode_utf8($content))); } @@ -35,12 +33,12 @@ sub dumpline ($$$$) { my $type=shift; my $prefix=shift; - eval q{use YAML::Old}; - eval q{use YAML} if $@; + eval q{use YAML::XS}; die $@ if $@; - $YAML::UseHeader=0; + $YAML::XS::QuoteNumericStrings=0; - my $dump=Dump({$key => $value}); + my $dump=decode_utf8(Dump({$key => $value})); + $dump=~s/^---\n//; # yaml header, we don't want chomp $dump; if (length $prefix) { $dump=join("\n", map { $prefix.$_ } split(/\n/, $dump)); diff --git a/debian/changelog b/debian/changelog index d014abd50..dbc9b16a5 100644 --- a/debian/changelog +++ b/debian/changelog @@ -2,6 +2,7 @@ ikiwiki (3.20120116) UNRELEASED; urgency=low * mdwn: Added nodiscount setting, which can be used to avoid using the markdown discount engine, when maximum compatability is needed. + * Switch to YAML::XS to work around insanity in YAML::Mo. Closes: #657533 -- Joey Hess Mon, 16 Jan 2012 13:41:14 -0400 diff --git a/debian/control b/debian/control index 922fe3c77..9403dfb44 100644 --- a/debian/control +++ b/debian/control @@ -7,7 +7,7 @@ Build-Depends-Indep: dpkg-dev (>= 1.9.0), libxml-simple-perl, libtimedate-perl, libhtml-template-perl, libhtml-scrubber-perl, wdg-html-validator, libhtml-parser-perl, liburi-perl (>= 1.36), perlmagick, po4a (>= 0.34), - libfile-chdir-perl, libyaml-perl, python-support + libfile-chdir-perl, libyaml-libyaml-perl, python-support Maintainer: Joey Hess Uploaders: Josh Triplett Standards-Version: 3.9.2 @@ -19,7 +19,7 @@ Architecture: all Depends: ${misc:Depends}, ${perl:Depends}, ${python:Depends}, libtext-markdown-discount-perl, libhtml-scrubber-perl, libhtml-template-perl, - libhtml-parser-perl, liburi-perl (>= 1.36), libyaml-perl, libjson-perl + libhtml-parser-perl, liburi-perl (>= 1.36), libyaml-libyaml-perl, libjson-perl Recommends: gcc | c-compiler, libc6-dev | libc-dev, git (>= 1:1.7) | git-core (>= 1:1.5.0) | subversion | tla | bzr (>= 0.91) | mercurial | monotone (>= 0.38) | darcs, diff --git a/ikiwiki.in b/ikiwiki.in index adff1411e..e6b64f439 100755 --- a/ikiwiki.in +++ b/ikiwiki.in @@ -108,11 +108,9 @@ sub getconfig () { if (! defined $var || ! defined $val) { die gettext("usage: --set-yaml var=value"), "\n"; } - eval q{use YAML::Any}; - eval q{use YAML} if $@; + eval q{use YAML::XS; use Encode}; die $@ if $@; - eval q{$YAML::Syck::ImplicitUnicode=1}; - $config{$var}=Load($val."\n"); + $config{$var}=Load(encode_utf8($val)."\n"); }, "version" => sub { print "ikiwiki version $IkiWiki::version\n"; -- 2.32.0.93.g670b81a890