]> sipb.mit.edu Git - ikiwiki.git/blob - doc/bugs/structured_config_data_is_mangled.mdwn
Merge remote-tracking branch 'remotes/smcv/ready/careful-eval'
[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 ~~~
49
50 > `getsetup` defines config options to be one of: boolean, string, integer,
51 > pagespec, "internal" (non-user-visible string), ref to an array of one of
52 > those scalar types, or ref to a hash { string => one of those scalar types }.
53 > IkiWiki::Setup also appears to support regexps (qr//), although that's
54 > not documented (presumably they're treated the same as strings).
55
56 > Supporting arbitrary arrays/hashes as values would require some way to
57 > untaint the values recursively.
58 >
59 > Complex config data also can't be used with the [[plugins/websetup]]
60 > plugin, which currently supports everything that IkiWiki::Setup does,
61 > except for hashes. --[[smcv]]