aboutsummaryrefslogtreecommitdiff
path: root/doc/bugs/pagespec_parsing_chokes_on_function__40____41__.mdwn
blob: 78fed0e5db5eae2a9b4e73aee89bfa8910136a67 (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
62
63
64
The pagespec regexes don't allow functions with no arguments.

IkiWiki.pm, around line 1035:

<pre>
$spec=~m{
                \s*             # ignore whitespace
                (               # 1: match a single word
                        \!              # !
                |
                        \(              # (
                |
                        \)              # )
                |
                        \w+\([^\)]+\)   # command(params)
                |
                        [^\s()]+        # any other text
                )
                \s*             # ignore whitespace
        }igx
</pre>

command(params) of course might be just command(). (See 
conditional.pm: match_included.) Trying to feed 
ikiwiki a pagespec without params will get you instead:

IkiWiki::PageSpec::match_glob($page, q{function}, @params) ( )

Which is completely not desired. The second + on that line should be a *.

None of the builtin pagespecs "work" with no parameters, so it's hard to 
write a unit test for this. But can we at least write a helpful note in
case the user is given to rebuilding the wiki by hand. --Ethan

<pre>
--- ikiwiki/IkiWiki.pm	2007-07-26 15:15:22.716860000 -0700
+++ ikidev/IkiWiki.pm	2007-07-26 21:34:45.542248000 -0700
@@ -1032,7 +1032,7 @@
 		|
 			\)		# )
 		|
-			\w+\([^\)]+\)	# command(params)
+			\w+\([^\)]*\)	# command(params)
 		|
 			[^\s()]+	# any other text
 		)
@@ -1075,6 +1075,10 @@
 	}
 
 	my $ret=eval pagespec_translate($spec);
+	if ($@){
+		my $t = pagespec_translate($spec);
+		print "evaluating pagespec failed: $t $@\n";
+	}
 	return IkiWiki::FailReason->new("syntax error") if $@;
 	return $ret;
 }
</pre>

> Thanks, [[done]] --[[Joey]]
>
> Note that the printing of the error isn't needed though. pagespec_match()
> returns an IkiWiki::FailReason object if parsing fails, and its caller
> can use that as desired to print the error.