From fe5e9b639d6510985c202dc4019704918b67f424 Mon Sep 17 00:00:00 2001 From: dairiki Date: Thu, 8 Feb 2001 18:28:31 +0000 Subject: [PATCH] Propagate bug fixes from MAIN CVS branch into the stable release branch. I have not added Arno's new transform.php code. Should we? (Is it functionally equivalent to the old code?) git-svn-id: svn://svn.code.sf.net/p/phpwiki/code/branches/release-1_2-branch@422 96ab9672-09ca-45d6-a79d-3d69d39ca109 --- HISTORY | 8 ++++ lib/config.php | 9 ++-- lib/diff.php | 85 ++++++++++++++++++++++++------------- lib/display.php | 9 ++-- lib/savepage.php | 11 +++-- lib/stdlib.php | 6 +-- lib/ziplib.php | 4 +- pgsrc/AddingPages | 2 +- pgsrc/HowToUseWiki | 2 +- pgsrc/PhpWikiAdministration | 2 +- pgsrc/TextFormattingRules | 6 +-- 11 files changed, 92 insertions(+), 52 deletions(-) diff --git a/HISTORY b/HISTORY index 8c1fcd06f..003de4d38 100644 --- a/HISTORY +++ b/HISTORY @@ -1,3 +1,11 @@ +* Don't show signature image if $SignatureImg (in config.php) is left unset +* Bug fix: hang on full zip dump +* Bug fix: hang on diff +* Bug fix: unzip failed on some old zip-dumps +* Bug fix: check for DB files in /tmp was broken +* Minor security fix: pagename must now be url-encoded +* Spelling fixes in pgsrc/* + 1.2.0 02/01/01 * Support for PHP 4.0.4 (using the dba_* interface for DBM files), thanks to Joel Uckelman diff --git a/lib/config.php b/lib/config.php index d151ff48b..731e0a57e 100644 --- a/lib/config.php +++ b/lib/config.php @@ -10,7 +10,7 @@ if (!function_exists('rcs_id')) { function rcs_id($id) { echo "\n"; }; } - rcs_id('$Id: config.php,v 1.24 2001-01-31 07:38:10 ahollosi Exp $'); + rcs_id('$Id: config.php,v 1.24.2.1 2001-02-08 18:28:31 dairiki Exp $'); // end essential internal stuff @@ -135,7 +135,9 @@ // logo image (path relative to index.php) $logo = "images/wikibase.png"; - // signature image which is shown after saving an edited page + + // Signature image which is shown after saving an edited page + // If this is left blank (or unset), the signature will be omitted. $SignatureImg = "images/signature.png"; // date & time formats used to display modification times, etc. @@ -232,9 +234,6 @@ if (defined('WIKI_ADMIN') && !empty($AdminUrl)) $ScriptUrl = $AdminUrl; - $LogoImage = "\"[PhpWiki!]\""; - $LogoImage = "$LogoImage"; - $FieldSeparator = "\263"; if (isset($PHP_AUTH_USER)) { diff --git a/lib/diff.php b/lib/diff.php index 3123ab5a9..2c07fdace 100644 --- a/lib/diff.php +++ b/lib/diff.php @@ -1,4 +1,4 @@ - + 0 && $n_to > 0) @@ -71,13 +78,11 @@ class _WikiDiffEngine $line = $from_lines[$x + $skip]; $xlines[] = $line; if ( ($this->xchanged[$x] = empty($yhash[$line])) ) - continue; // fixme? what happens to yhash/xhash when - // there are two identical lines?? + continue; $this->xv[] = $line; $this->xind[] = $x; } - // Find the LCS. $this->_compareseq(0, sizeof($this->xv), 0, sizeof($this->yv)); @@ -94,15 +99,13 @@ class _WikiDiffEngine $y = 0; while ($x < $n_from || $y < $n_to) { - /* - if ( ($y == $n_to && !$this->xchanged[$x]) - || ($x == $n_from && !$this->ychanged[$y]) ) - die("assertion error"); - */ + USE_ASSERTS && assert($y < $n_to || $this->xchanged[$x]); + USE_ASSERTS && assert($x < $n_from || $this->ychanged[$y]); // Skip matching "snake". $x0 = $x; $ncopy = 0; + while ( $x < $n_from && $y < $n_to && !$this->xchanged[$x] && !$this->ychanged[$y]) { @@ -133,7 +136,7 @@ class _WikiDiffEngine $this->edits[] = $adds; } } - if (!empty($endskip)) + if ($endskip != 0) $this->edits[] = $endskip; } @@ -195,7 +198,7 @@ class _WikiDiffEngine if (! $this->in_seq[$y]) { $k = $this->_lcs_pos($y); - //if (!$k) die('assertion "!$k" failed'); + USE_ASSERTS && assert($k > 0); $ymids[$k] = $ymids[$k-1]; break; } @@ -203,7 +206,7 @@ class _WikiDiffEngine { if ($y > $this->seq[$k-1]) { - //if ($y >= $this->seq[$k]) die('assertion failed'); + USE_ASSERTS && assert($y < $this->seq[$k]); // Optimization: this is a common case: // next match is just replacing previous match. $this->in_seq[$this->seq[$k]] = false; @@ -213,7 +216,7 @@ class _WikiDiffEngine else if (! $this->in_seq[$y]) { $k = $this->_lcs_pos($y); - //if (!$k) die('assertion "!$k" failed'); + USE_ASSERTS && assert($k > 0); $ymids[$k] = $ymids[$k-1]; } } @@ -253,7 +256,7 @@ class _WikiDiffEngine $end = $mid; } - //if ($ypos == $this->seq[$end]) die("assertion failure"); + USE_ASSERTS && assert($ypos != $this->seq[$end]); $this->in_seq[$this->seq[$end]] = false; $this->seq[$end] = $ypos; @@ -328,7 +331,7 @@ class _WikiDiffEngine * as much as possible. * * We do something when a run of changed lines include a - * line at one end and have an excluded, identical line at the other. + * line at one end and has an excluded, identical line at the other. * We are free to choose which identical line is included. * `compareseq' usually chooses the one at the beginning, * but usually it is cleaner to consider the following identical line @@ -340,18 +343,33 @@ class _WikiDiffEngine { $i = 0; $j = 0; + + USE_ASSERTS && assert('sizeof($lines) == sizeof($changed)'); $len = sizeof($lines); + $other_len = sizeof($other_changed); + while (1) { /* * Scan forwards to find beginning of another run of changes. * Also keep track of the corresponding point in the other file. + * + * Throughout this code, $i and $j are adjusted together so that + * the first $i elements of $changed and the first $j elements + * of $other_changed both contain the same number of zeros + * (unchanged lines). + * Furthermore, $j is always kept so that $j == $other_len or + * $other_changed[$j] == false. */ - while ($i < $len && $changed[$i] == 0) + while ($j < $other_len && $other_changed[$j]) + $j++; + + while ($i < $len && ! $changed[$i]) { - while ($other_changed[$j++]) - continue; - $i++; + USE_ASSERTS && assert('$j < $other_len && ! $other_changed[$j]'); + $i++; $j++; + while ($j < $other_len && $other_changed[$j]) + $j++; } if ($i == $len) @@ -360,10 +378,8 @@ class _WikiDiffEngine $start = $i; // Find the end of this run of changes. - while (isset($changed[++$i])) + while (++$i < $len && $changed[$i]) continue; - while ($other_changed[$j]) - $j++; do { @@ -378,14 +394,16 @@ class _WikiDiffEngine * previous unchanged line matches the last changed one. * This merges with previous changed regions. */ - while ($start && $lines[$start - 1] == $lines[$i - 1]) + while ($start > 0 && $lines[$start - 1] == $lines[$i - 1]) { $changed[--$start] = 1; $changed[--$i] = false; - while ($changed[$start - 1]) + while ($start > 0 && $changed[$start - 1]) $start--; + USE_ASSERTS && assert('$j > 0'); while ($other_changed[--$j]) continue; + USE_ASSERTS && assert('$j >= 0 && !$other_changed[$j]'); } /* @@ -393,7 +411,7 @@ class _WikiDiffEngine * point where it corresponds to a changed run in the other file. * CORRESPONDING == LEN means no such point has been found. */ - $corresponding = empty($other_changed[$j - 1]) ? $len : $i; + $corresponding = $j < $other_len ? $i : $len; /* * Move the changed region forward, so long as the @@ -402,14 +420,21 @@ class _WikiDiffEngine * Do this second, so that if there are no merges, * the changed region is moved forward as far as possible. */ - while ($i != $len && $lines[$start] == $lines[$i]) + while ($i < $len && $lines[$start] == $lines[$i]) { $changed[$start++] = false; $changed[$i++] = 1; - while ($changed[$i]) + while ($i < $len && $changed[$i]) $i++; - while ($other_changed[++$j]) + + USE_ASSERTS && assert('$j < $other_len && ! $other_changed[$j]'); + $j++; + if ($j < $other_len && $other_changed[$j]) + { $corresponding = $i; + while ($j < $other_len && $other_changed[$j]) + $j++; + } } } while ($runlength != $i - $start); @@ -422,8 +447,10 @@ class _WikiDiffEngine { $changed[--$start] = 1; $changed[--$i] = 0; + USE_ASSERTS && assert('$j > 0'); while ($other_changed[--$j]) continue; + USE_ASSERTS && assert('$j >= 0 && !$other_changed[$j]'); } } } @@ -481,7 +508,7 @@ class WikiDiff if (is_array($edit)) { // Was an add, turn it into a delete. $nadd = sizeof($edit); - if ($nadd == 0) die("assertion error"); + USE_ASSERTS && assert ($nadd > 0); $edit = -$nadd; } else if ($edit > 0) diff --git a/lib/display.php b/lib/display.php index 0629e15c9..fb378cbdc 100644 --- a/lib/display.php +++ b/lib/display.php @@ -1,13 +1,16 @@ Warning: the Wiki DBM file still lives in the " . + if (isset($DBMdir) && preg_match('@^/tmp\b@', $DBMdir)) { + $html .= "

Warning: the Wiki DB files still live in the " . "/tmp directory. Please read the INSTALL file and move " . "the DBM file to a permanent location or risk losing " . "all the pages!\n"; } - $html .= "


"; + if (!empty($SignatureImg)) + $html .= "

\n"; + + $html .= "

"; include('lib/transform.php'); GeneratePage('BROWSE', $html, $pagename, $pagehash); diff --git a/lib/stdlib.php b/lib/stdlib.php index 994bc3aba..6a1fa50ce 100644 --- a/lib/stdlib.php +++ b/lib/stdlib.php @@ -1,10 +1,10 @@ -

list @@ -51,7 +51,7 @@ will not work'' * Hyperlinks to other pages within the Wiki are made by placing the page name in square brackets: [this is a page link] or UsingWikiWords (preferred) * Hyperlinks to external pages are done like this: [http://www.wcsb.org/] * You can name the links by providing a name, a bar (|) and then the hyperlink or pagename: [PhpWiki home page | http://phpwiki.sourceforge.net/] - [the front page | FrontPage] -* You can suppress linking to old-style references and URIs by preceeding the word with a '!', e.g. !NotLinkedAsWikiName, !http://not.linked.to/ +* You can suppress linking to old-style references and URIs by preceding the word with a '!', e.g. !NotLinkedAsWikiName, !http://not.linked.to/ * [1], [2], [3], [4] refer to remote references. Click EditLinks on the edit form to enter URLs. These differ from the newer linking scheme; references are unique to a page. * Also, the old way of linking URL's is still supported: precede URLs with "http:", "ftp:" or "mailto:" to create links automatically as in: http://c2.com/ * URLs ending with .png, .gif, or .jpg are inlined if in square brackets, by themselves: [http://phpwiki.sourceforge.net/phpwiki/images/png.png] -- 2.45.0