]> sipb.mit.edu Git - ikiwiki.git/blob - doc/bugs/Warns_about_use_of_uninitialized_value_if_prefix__95__directives_is_on_and_a_directive_does_not_contain_a_space.mdwn
Tag patches with the plugin to which they apply, or core
[ikiwiki.git] / doc / bugs / Warns_about_use_of_uninitialized_value_if_prefix__95__directives_is_on_and_a_directive_does_not_contain_a_space.mdwn
1 In `IkiWiki::preprocess`, the last capturing group in the regex used to parse directives in prefix_directives mode is of the form `(\s+...)?\]\]`, which will not be matched if the directive is something without arguments or whitespace, like `\[[!orphans]]`. As a result, its value is undef instead of being an empty string, causing a warning when it is used in the anonymous sub `$handle`. A trivial fix is to treat it as "" if it is undef.
2
3 [[patch]] in the master branch of my git repository, and quoted here. --[[smcv]]
4
5     diff --git a/IkiWiki.pm b/IkiWiki.pm
6     index 241a7c0..d2c35a2 100644
7     --- a/IkiWiki.pm
8     +++ b/IkiWiki.pm
9     @@ -1167,7 +1167,8 @@ sub preprocess ($$$;$$) {
10                     }sx;
11             }
12      
13     -       $content =~ s{$regex}{$handle->($1, $2, $3, $4)}eg;
14     +       # $4 can be undef if the directive was \[[!foo]]
15     +       $content =~ s{$regex}{$handle->($1, $2, $3, ($4 or ""))}eg;
16             return $content;
17      }
18  
19 [[cherry-picked|done]] --[[Joey]]