From 64cb260e4f8a070564b2579781a1e974fa53b289 Mon Sep 17 00:00:00 2001 From: rurban Date: Wed, 3 Nov 2004 16:55:03 +0000 Subject: [PATCH] pcre crash and mysql helpers git-svn-id: svn://svn.code.sf.net/p/phpwiki/code/trunk@4084 96ab9672-09ca-45d6-a79d-3d69d39ca109 --- tests/unit/mysql-test-destroy.sql | 16 +++++ tests/unit/mysql-test-initialize.sql | 88 ++++++++++++++++++++++++++++ tests/unit/pcre-crash.php | 45 ++++++++++++++ 3 files changed, 149 insertions(+) create mode 100644 tests/unit/mysql-test-destroy.sql create mode 100644 tests/unit/mysql-test-initialize.sql create mode 100755 tests/unit/pcre-crash.php diff --git a/tests/unit/mysql-test-destroy.sql b/tests/unit/mysql-test-destroy.sql new file mode 100644 index 000000000..295c04ad4 --- /dev/null +++ b/tests/unit/mysql-test-destroy.sql @@ -0,0 +1,16 @@ +-- $Id: mysql-test-destroy.sql,v 1.1 2004-11-03 16:55:03 rurban Exp $ + +drop table if exists test_page; +drop table if exists test_version; +drop table if exists test_recent; +drop table if exists test_nonempty; +drop table if exists test_link; +drop table if exists test_session; + +-- since 1.3.7: + +drop table if exists test_pref; +drop table if exists test_user; +drop table if exists test_member; + +drop table if exists test_rating; diff --git a/tests/unit/mysql-test-initialize.sql b/tests/unit/mysql-test-initialize.sql new file mode 100644 index 000000000..a1bc4a4d2 --- /dev/null +++ b/tests/unit/mysql-test-initialize.sql @@ -0,0 +1,88 @@ +-- $Id: mysql-test-initialize.sql,v 1.1 2004-11-03 16:55:03 rurban Exp $ +-- for the regression suite + +CREATE TABLE test_page ( + id INT NOT NULL AUTO_INCREMENT, + pagename VARCHAR(100) BINARY NOT NULL, + hits INT NOT NULL DEFAULT 0, + pagedata MEDIUMTEXT NOT NULL DEFAULT '', + PRIMARY KEY (id), + UNIQUE KEY (pagename) +); + +CREATE TABLE test_version ( + id INT NOT NULL, + version INT NOT NULL, + mtime INT NOT NULL, + minor_edit TINYINT DEFAULT 0, + content MEDIUMTEXT NOT NULL DEFAULT '', + versiondata MEDIUMTEXT NOT NULL DEFAULT '', + PRIMARY KEY (id,version), + INDEX (mtime) +); + +CREATE TABLE test_recent ( + id INT NOT NULL, + latestversion INT, + latestmajor INT, + latestminor INT, + PRIMARY KEY (id) +); + +CREATE TABLE test_nonempty ( + id INT NOT NULL, + PRIMARY KEY (id) +); + +CREATE TABLE test_link ( + linkfrom INT NOT NULL, + linkto INT NOT NULL, + INDEX (linkfrom), + INDEX (linkto) +); + +CREATE TABLE test_session ( + sess_id CHAR(32) NOT NULL DEFAULT '', + sess_data BLOB NOT NULL, + sess_date INT UNSIGNED NOT NULL, + sess_ip CHAR(15) NOT NULL, + PRIMARY KEY (sess_id), + INDEX (sess_date) +); -- TYPE=heap; -- if your Mysql supports it and you have enough RAM + +-- upgrade to 1.3.8: (see lib/upgrade.php) +-- ALTER TABLE session ADD sess_ip CHAR(15) NOT NULL; +-- CREATE INDEX sess_date on session (sess_date); +-- update to 1.3.10: (see lib/upgrade.php) +-- ALTER TABLE page CHANGE id id INT NOT NULL AUTO_INCREMENT; + +-- Optional DB Auth and Prefs +-- For these tables below the default table prefix must be used +-- in the DBAuthParam SQL statements also. + +CREATE TABLE test_pref ( + userid CHAR(48) BINARY NOT NULL UNIQUE, + prefs TEXT NULL DEFAULT '', + PRIMARY KEY (userid) +) TYPE=MyISAM; + +-- better use the extra pref table where such users can be created easily +-- without password. +CREATE TABLE test_user ( + userid CHAR(48) BINARY NOT NULL UNIQUE, + passwd CHAR(48) BINARY DEFAULT '', +-- prefs TEXT NULL DEFAULT '', +-- groupname CHAR(48) BINARY DEFAULT 'users', + PRIMARY KEY (userid) +) TYPE=MyISAM; + +-- only if you plan to use the wikilens theme +CREATE TABLE test_rating ( + dimension INT(4) NOT NULL, + raterpage INT(11) NOT NULL, + rateepage INT(11) NOT NULL, + ratingvalue FLOAT NOT NULL, + rateeversion INT(11) NOT NULL, + tstamp TIMESTAMP(14) NOT NULL, + PRIMARY KEY (dimension, raterpage, rateepage) +); diff --git a/tests/unit/pcre-crash.php b/tests/unit/pcre-crash.php new file mode 100755 index 000000000..e599165fe --- /dev/null +++ b/tests/unit/pcre-crash.php @@ -0,0 +1,45 @@ +\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"; + +?> \ No newline at end of file -- 2.45.0