[chora] bug && bugfix again...

Mathieu Arnold arn_mat@club-internet.fr
Tue, 10 Apr 2001 01:41:50 +0200


---------------------- multipart/mixed attachment


Mathieu Arnold wrote:
> 
> I really like my developers who use files with spaces in them...

and to prevent problems with other char as well, here's a pretty patch.
if you need some explanations on a point, feel free to ask ;)

-- 
Mathieu Arnold
---------------------- multipart/mixed attachment
Index: common.php
===================================================================
RCS file: /home/cvs/cvs/dup/horde/chora/common.php,v
retrieving revision 1.35
diff -u -r1.35 common.php
--- common.php	2001/04/09 15:57:18	1.35
+++ common.php	2001/04/09 23:36:01
@@ -175,7 +175,8 @@
 }
 
 /* Location relative to the CVSROOT */
-$where = preg_replace("|^/|", '', $HTTP_SERVER_VARS['PATH_INFO']);
+$where = stripslashes($HTTP_SERVER_VARS['PATH_INFO']);
+$where = preg_replace("|^/|", '', $where);
 $where = preg_replace("|\.\.|", '', $where);
 $where = preg_replace('|/$|', '', $where); 
 
@@ -200,7 +201,7 @@
 function url($script, $uri='', $args = array(), $anchor='')
 {
     global $scriptPath;
-    $url = $scriptPath . '/' . $script . '.php' . '/' . $uri;
+    $url = $scriptPath . '/' . $script . '.php' . '/' . rawurlencode($uri);
     $arglist = array_merge(differingVars(), $args);
     $argarr = array();
     while (list($key, $val) = each($arglist)) {
@@ -222,11 +223,39 @@
     }
 
     $url = preg_replace('|/\?|','?',$url);
-    return htmlspecialchars(preg_replace('|/+|','/',$url)); 
+    $url = preg_replace('|/+|','/',$url);
+    $url = preg_replace('|%2F|','/',$url);
+    return $url;
 }
 
 function graphic($name) {
     global $scriptPath;
     return $scriptPath.'/graphics/'.$name; 
+}
+
+/**
+  * Convert a line of text to be HTML-displayable
+  * @param text The line of text to convert
+  * @return The HTML-compliant converted text.  It always returns at least
+  *         a non-breakable space, if the return would otherwise be empty.
+  */
+function htmlspaces($text='') {
+    $text = htmlentities($text);
+    $text = str_replace("\t", '        ', $text);
+    $text = str_replace('  ', '  ', $text);
+    $text = str_replace('  ', '  ', $text);
+    return empty($text)?' ':$text;
+}
+
+/**
+  * Same as before but convert all spaces to  
+  * @param text the line of text to convert
+  * @return The HTML-compliant converted text.  It always returns at least
+  *         a non-breakable space, if the return would otherwise be empty.
+  */
+function htmlallspaces($text='') {
+    $text = htmlspaces($text);
+    $text = str_replace(' ', ' ', $text);
+    return $text;
 }
 ?>
Index: cvs.php
===================================================================
RCS file: /home/cvs/cvs/dup/horde/chora/cvs.php,v
retrieving revision 1.83
diff -u -r1.83 cvs.php
--- cvs.php	2001/04/09 15:53:35	1.83
+++ cvs.php	2001/04/09 23:36:01
@@ -72,14 +72,15 @@
     while (list(,$currFile) = each($fileList)) {
         $dirrow = (++$dirrow % 2);
         $lg = $currFile->queryLastLog();
-        $name = $currFile->queryName();
+        $realname = $currFile->queryName();
         $aid = $lg->queryAuthor();
         $author = showAuthorName($aid);
         $head = $currFile->queryHead();
         $date = $lg->queryDate();
         $log  = $lg->queryLog();
         $attic = $currFile->isAtticFile();
-        $fileName = $where.($attic?'/Attic':'')."/$name";
+        $fileName = $where.($attic?'/Attic':'')."/$realname";
+        $name = htmlallspaces($realname);
         $url = url('cvs',$fileName);
         $readableDate = CVSLib_File::readableTime($date);
         if ($log) {
Index: diff.php
===================================================================
RCS file: /home/cvs/cvs/dup/horde/chora/diff.php,v
retrieving revision 1.26
diff -u -r1.26 diff.php
--- diff.php	2001/04/09 15:53:35	1.26
+++ diff.php	2001/04/09 23:36:01
@@ -9,20 +9,6 @@
  * did not receive this file, see http://www.fsf.org/copyleft/gpl.html.
  */
 
-/**
-  * Convert a line of text to be HTML-displayable
-  * @param text The line of text to convert
-  * @return The HTML-compliant converted text.  It always returns at least
-  *         a non-breakable space, if the return would otherwise be empty.
-  */
-function htmlspaces($text='') {
-    $text = htmlspecialchars($text);
-    $text = str_replace("\t", '        ', $text);
-    $text = str_replace('  ', '  ', $text);
-    $text = str_replace('  ', '  ', $text);
-    return empty($text)?' ':$text;
-}
-
 require_once dirname(__FILE__).'/common.php';
 
 /* Spawn the repository and file objects */

---------------------- multipart/mixed attachment--