Switch to YAML::XS to work around insanity in YAML::Mo. Closes: #657533
authorJoey Hess <joey@kitenet.net>
Sun, 29 Jan 2012 02:01:49 +0000 (22:01 -0400)
committerJoey Hess <joey@kitenet.net>
Sun, 29 Jan 2012 02:36:14 +0000 (22:36 -0400)
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
IkiWiki/Setup/Yaml.pm
debian/changelog
debian/control
ikiwiki.in

index a0bd60e46abdf9425b0f01b1ab7dee3af3c73ebe..0059362507117ed9ae9dc92ea38ac1a312b4c06f 100644 (file)
@@ -28,7 +28,7 @@ CGI::Session
 Mail::Sendmail
 CGI
 Data::Dumper
-YAML
+YAML::XS
 JSON
 RPC::XML
 
index 6da93bb644bb5f639dd6871b492782cfa059345d..6bf20f480d523ad5144dc6d1b61ec03d1f0118b5 100644 (file)
@@ -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));
index d014abd50e0c4a6cf18dcf8d9fe3c998e0b08b9d..dbc9b16a555f89b1eb29bd2a6dc650ceca9e2616 100644 (file)
@@ -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 <joeyh@debian.org>  Mon, 16 Jan 2012 13:41:14 -0400
 
index 922fe3c7772d2538377c45b9d6751a195181ab3f..9403dfb442fdd5a45d5aeaebaad21fb87e9497f6 100644 (file)
@@ -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 <joeyh@debian.org>
 Uploaders: Josh Triplett <josh@freedesktop.org>
 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,
index adff1411e8aa715a192f3850a7aef59f4cd04f0b..e6b64f43949aba391a411c31b1cf57a0c8b56c2e 100755 (executable)
@@ -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";