File: pcre-crash.php

package info (click to toggle)
phpwiki 1.3.14-3
  • links: PTS
  • area: main
  • in suites: lenny
  • size: 15,716 kB
  • ctags: 23,548
  • sloc: php: 88,295; sql: 1,476; sh: 1,378; perl: 765; makefile: 602; awk: 28
file content (45 lines) | stat: -rwxr-xr-x 1,140 bytes parent folder | download | duplicates (4)
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
<?php
	$blockpats=array();

        $blockpats[] = '[ \t]+\S(?:.*\s*\n[ \t]+\S)*';
        // Tables
        $blockpats[] = '\|(?:.*\n\|)*';

        // List items
        $blockpats[] = '[#*;]*(?:[*#]|;.*?:)';

        // Footnote definitions
        $blockpats[] = '\[\s*(\d+)\s*\]';

        if (0 and !$debug_skip) {
        // Plugins
        $blockpats[] = '<\?plugin(?:-form)?\b.*\?>\s*$';
        }

        // Section Title
        $blockpats[] = '!{1,3}[^!]';

        $block_re = ( '/\A((?:.|\n)*?)(^(?:'
                      . join("|", $blockpats)
                      . ').*$)\n?/m' );


$pat = "/\A(
  (?:.|\n)*?)
  (^ (?:[ \t]+\S
       (?:.*\s*\n[ \t]+\S)* |
       \|(?:.*\n\|)* | [#*;]*(?:[*#]|;.*?:) | 
       \[\s*(\d+)\s*\] |
       <\?plugin(?:-form)?\b.*\?>\s*$ |
       !{1,3}[^!])
  .*$)\n?/Axm";

//     /\A((?:.|\n)*?)(^(?:[ \t]+\S(?:.*\s*\n[ \t]+\S)*|\|(?:.*\n\|)*|[#*;]*(?:[*#]|;.*?:)|\[\s*(\d+)\s*\]|!{1,3}[^!]).*$)\n?/m

// cli works fine, but sapi (Apache/2.0.48 or Apache 1) crashes.
$subj = str_repeat("123456789 ", 200);
preg_match($pat, $subj, $m);
//preg_match($block_re, $subj, $m);
echo "ok\n";

?>