]> sipb.mit.edu Git - ikiwiki.git/blob - doc/bugs/structured_config_data_is_mangled.mdwn
Merge branch 'master' of ssh://git.ikiwiki.info
[ikiwiki.git] / doc / bugs / structured_config_data_is_mangled.mdwn
1 Put something like this in the setup file:
2
3 ~~~
4 conversion:
5   - from: odt
6     to: pdf
7     command: [unoconv, -f, pdf, -o, $OUTPUTDIR, $INPUTFILE]
8   - from: ditaa
9     to: png
10     command: [ditaa, $INPUTFILE, $OUTPUTFILE, -s, 0.7]
11 ~~~
12
13 However `Dumper($config{conversion})` shows:
14
15 ~~~
16 $VAR1 = [
17           'HASH(0x164e1a0)',
18           'HASH(0x164e3c8)'
19         ];
20 ~~~
21
22 I think it is getting mangled in `sub merge` in `IkiWiki/Setup.pm` and its calls to `possibly_foolish_untaint`
23
24 Workaround: force the array values to be strings, and then re-parse them using YAML::XS::Load:
25
26 ~~~
27 conversion:
28   - |
29     from: [odt, odp]
30     to: pdf
31     command: [unoconv, -f, pdf, -o, $OUTPUTDIR, $INPUTFILE]
32   - |
33     from: ditaa
34     to: png
35     command: [ditaa, $INPUTFILE, $OUTPUTFILE, -s, 0.7]
36
37 ...
38
39 sub checkconfig {
40     if (!defined $config{conversion} || ref $config{conversion} ne "ARRAY") {
41         error(sprintf(gettext("Must specify '%s' and it must be a list"), "conversion"));
42     }
43     for (my $i=0; $i < @{$config{conversion}}; $i++) {
44       $config{conversion}->[$i] = YAML::XS::Load($config{conversion}->[$i]) if
45           ref $config{conversion}->[$i] ne 'HASH';
46     }
47 }
48 ~~~