aboutsummaryrefslogtreecommitdiff
path: root/doc/bugs/structured_config_data_is_mangled.mdwn
blob: 869d48e9676305a0892a1cccf6d9d1077e71e31a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
Put something like this in the setup file:

~~~
conversion:
  - from: odt
    to: pdf
    command: [unoconv, -f, pdf, -o, $OUTPUTDIR, $INPUTFILE]
  - from: ditaa
    to: png
    command: [ditaa, $INPUTFILE, $OUTPUTFILE, -s, 0.7]
~~~

However `Dumper($config{conversion})` shows:

~~~
$VAR1 = [
          'HASH(0x164e1a0)',
          'HASH(0x164e3c8)'
        ];
~~~

I think it is getting mangled in `sub merge` in `IkiWiki/Setup.pm` and its calls to `possibly_foolish_untaint`

Workaround: force the array values to be strings, and then re-parse them using YAML::XS::Load:

~~~
conversion:
  - |
    from: [odt, odp]
    to: pdf
    command: [unoconv, -f, pdf, -o, $OUTPUTDIR, $INPUTFILE]
  - |
    from: ditaa
    to: png
    command: [ditaa, $INPUTFILE, $OUTPUTFILE, -s, 0.7]

...

sub checkconfig {
    if (!defined $config{conversion} || ref $config{conversion} ne "ARRAY") {
        error(sprintf(gettext("Must specify '%s' and it must be a list"), "conversion"));
    }
    for (my $i=0; $i < @{$config{conversion}}; $i++) {
      $config{conversion}->[$i] = YAML::XS::Load($config{conversion}->[$i]) if
          ref $config{conversion}->[$i] ne 'HASH';
    }
}
~~~

> `getsetup` defines config options to be one of: boolean, string, integer,
> pagespec, "internal" (non-user-visible string), ref to an array of one of
> those scalar types, or ref to a hash { string => one of those scalar types }.
> IkiWiki::Setup also appears to support regexps (qr//), although that's
> not documented (presumably they're treated the same as strings).
> 
> Supporting arbitrary arrays/hashes as values would require some way to
> untaint the values recursively.
>
> Complex config data also can't be used with the [[plugins/websetup]]
> plugin, which currently supports everything that IkiWiki::Setup does,
> except for hashes. --[[smcv]]