Update of /cvsroot/phpwiki/phpwiki/lib
In directory usw-pr-cvs1:/tmp/cvs-serv15069/lib
Modified Files:
loadsave.php
Log Message:
Encode leading '.' in filenames for both zip dumps and dumps to
directories. (See SF bug #478449).
Index: loadsave.php
===================================================================
RCS file: /cvsroot/phpwiki/phpwiki/lib/loadsave.php,v
retrieving revision 1.9
retrieving revision 1.10
diff -C2 -r1.9 -r1.10
*** loadsave.php 2001/09/19 02:58:00 1.9
--- loadsave.php 2001/11/09 16:23:37 1.10
***************
*** 53,56 ****
--- 53,75 ----
}
+ /***
+ * Compute filename to used for storing contents of a wiki page.
+ *
+ * Basically we do a rawurlencode() which encodes everything
+ * except ASCII alphanumerics and '.', '-', and '_'.
+ *
+ * But we also want to encode leading dots to avoid filenames
+ * like '.', and '..'. (Also, there's no point in generating
+ * "hidden" file names, like '.foo'.)
+ *
+ * @param $pagename string Pagename.
+ * @return string Filename for page.
+ */
+ function FilenameForPage ($pagename)
+ {
+ $enc = rawurlencode($pagename);
+ return preg_replace('/^\./', '%2e', $enc);
+ }
+
/**
* The main() function which generates a zip archive of a PhpWiki.
***************
*** 94,98 ****
$content = MailifyPage($page);
! $zip->addRegularFile( rawurlencode($page->getName()),
$content, $attrib);
}
--- 113,117 ----
$content = MailifyPage($page);
! $zip->addRegularFile( FilenameForPage($page->getName()),
$content, $attrib);
}
***************
*** 123,127 ****
$enc_name = htmlspecialchars($page->getName());
! $filename = rawurlencode($page->getName());
echo "<br>$enc_name ... ";
--- 142,146 ----
$enc_name = htmlspecialchars($page->getName());
! $filename = FilenameForPage($page->getName());
echo "<br>$enc_name ... ";
|