CVS update: /cowiki/includes/cowiki/class/parse/, /cowiki/misc/development/tests/

[email protected] 12 Jun 2005 13:44:35 -0000
Newsgroups gmane.comp.php.cowiki.cvs
Message-ID <[email protected]>
User: cmarble 
Date: 2005/06/12 06:44:35

Modified:
   cowiki/includes/cowiki/class/parse/class.WikiParser.php
   cowiki/includes/cowiki/class/parse/class.WikiReverseParser.php
   cowiki/misc/development/tests/RunTests.php
   cowiki/misc/development/tests/class.ParserTest.php

Log:
 Issue number:  229
 
 code behaves like rem & noop (ignoring content).

File Changes:

Directory: /cowiki/includes/cowiki/class/parse/
===============================================

File [changed]: class.WikiParser.php
Url: http://cowiki.tigris.org/source/browse/cowiki/includes/cowiki/class/parse/class.WikiParser.php?r1=1.52&r2=1.53
Delta lines:  +7 -5
-------------------
--- class.WikiParser.php	31 May 2005 11:39:55 -0000	1.52
+++ class.WikiParser.php	12 Jun 2005 13:44:30 -0000	1.53
@@ -2,7 +2,7 @@
 
 /**
  *
- * $Id: class.WikiParser.php,v 1.52 2005/05/31 11:39:55 cmarble Exp $
+ * $Id: class.WikiParser.php,v 1.53 2005/06/12 13:44:30 cmarble Exp $
  *
  * This file is part of coWiki. coWiki is free software under the terms of
  * the GNU General Public License (GPL). Read the LICENSE file. If you did
@@ -21,7 +21,7 @@
  * @author      Daniel T. Gorski, <[email protected]>
  * @copyright   (C) Daniel T. Gorski, {@link http://www.develnet.org}
  * @license     http://www.gnu.org/licenses/gpl.html
- * @version     $Revision: 1.52 $
+ * @version     $Revision: 1.53 $
  *
  */
 
@@ -317,7 +317,7 @@
             } else {
                 if($debug) { echo "pre finalize sRow ".$sRow."\n"; }
                 $sRet .= $this->finalizeList( $sRow );
-                if($debug) { echo "post finalize sRow ".$sRow."\n"; }
+                if($debug) { echo "post finalize sRet ".$sRet."\n"; }
             }
             if(isset($aMatches[0])) {
                 $sRow = substr( $sRow, strlen( $aMatches[0] ) );
@@ -329,6 +329,7 @@
                     $sRow = $this->aRows[$this->iRow];
                     $bBegin = true;
                 } else {
+                    if($debug) { echo "broken\n"; }
                     break;
                 }
             }
@@ -407,6 +408,7 @@
                     {
                         case 'rem':
                         case 'noop':
+                        case 'code':
                             $sRet .= '<'.$aMatch[1].'>'.$sContent .'</'.$aMatch[1].'>';
                             break;
                         default:

File [changed]: class.WikiReverseParser.php
Url: http://cowiki.tigris.org/source/browse/cowiki/includes/cowiki/class/parse/class.WikiReverseParser.php?r1=1.23&r2=1.24
Delta lines:  +5 -3
-------------------
--- class.WikiReverseParser.php	2 Jun 2005 19:22:05 -0000	1.23
+++ class.WikiReverseParser.php	12 Jun 2005 13:44:30 -0000	1.24
@@ -2,7 +2,7 @@
 
 /**
  *
- * $Id: class.WikiReverseParser.php,v 1.23 2005/06/02 19:22:05 cmarble Exp $
+ * $Id: class.WikiReverseParser.php,v 1.24 2005/06/12 13:44:30 cmarble Exp $
  *
  * This file is part of coWiki. coWiki is free software under the terms of
  * the GNU General Public License (GPL). Read the LICENSE file. If you did
@@ -17,7 +17,7 @@
  * @author      Daniel T. Gorski, <[email protected]>
  * @copyright   (C) Daniel T. Gorski, {@link http://www.develnet.org}
  * @license     http://www.gnu.org/licenses/gpl.html
- * @version     $Revision: 1.23 $
+ * @version     $Revision: 1.24 $
  *
  */
 
@@ -188,6 +188,7 @@
      */
     public function parse($sStr) {
 
+        $debug = false;
       //return $this->dummy($sStr);
 
         if (!function_exists('xml_parser_create')) {
@@ -229,7 +230,8 @@
         $lc = 0;
 
         while($lc < $max){ 
-            if(!xml_parse( $this->rParser, $aLines[$lc], ($lc==$max-1)))
+            if($debug) {echo "parsing ".$aLines[$lc]."\n";}
+            if(!xml_parse( $this->rParser, $aLines[$lc]."\n", ($lc==$max-1)))
             {
                 $this->appendRow( sprintf("XML error: %s\n",
                         xml_error_string(xml_get_error_code($this->rParser))));

Directory: /cowiki/misc/development/tests/
==========================================

File [changed]: RunTests.php
Url: http://cowiki.tigris.org/source/browse/cowiki/misc/development/tests/RunTests.php?r1=1.4&r2=1.5
Delta lines:  +6 -3
-------------------
--- RunTests.php	30 May 2005 16:54:07 -0000	1.4
+++ RunTests.php	12 Jun 2005 13:44:30 -0000	1.5
@@ -1,7 +1,7 @@
 <?php
 /**
  *
- * $Id: RunTests.php,v 1.4 2005/05/30 16:54:07 cmarble Exp $
+ * $Id: RunTests.php,v 1.5 2005/06/12 13:44:30 cmarble Exp $
  *
  * This file is part of coWiki. coWiki is free software under the terms of
  * the GNU General Public License (GPL). Read the LICENSE file. If you did
@@ -16,7 +16,7 @@
  * @author      Paul Hanchett <[email protected]>
  * @copyright   (C) Paul Hanchett, 2005
  * @license     http://www.gnu.org/licenses/gpl.html
- * @version     $Revision: 1.4 $
+ * @version     $Revision: 1.5 $
  *
  */
 //
@@ -53,10 +53,11 @@
 
 $suite->addTestSuite(ParserBadTagFormattingTest);
 
+
 $suite->addTestSuite(ParserNoopTagFormattingTest);
 $suite->addTestSuite(ParserRemTagFormattingTest);
-
 $suite->addTestSuite(ParserCodeTagFormattingTest);
+
 $suite->addTestSuite(ParserPreTagFormattingTest);
 $suite->addTestSuite(ParserPostingTagFormattingTest);
 $suite->addTestSuite(ParserQTagFormattingTest);
@@ -64,6 +65,8 @@
 $suite->addTestSuite(ParserOtherProcessContentFormattingTest);
 
 $suite->addTestSuite(ParserOtherParseFormattingTest);
+
+//$suite->addTestSuite(ParserBlockFormattingTest);
 
 $suite->run($result);
 

File [changed]: class.ParserTest.php
Url: http://cowiki.tigris.org/source/browse/cowiki/misc/development/tests/class.ParserTest.php?r1=1.4&r2=1.5
Delta lines:  +76 -12
---------------------
--- class.ParserTest.php	30 May 2005 17:08:37 -0000	1.4
+++ class.ParserTest.php	12 Jun 2005 13:44:30 -0000	1.5
@@ -1,7 +1,7 @@
 <?php
 /**
  *
- * $Id: class.ParserTest.php,v 1.4 2005/05/30 17:08:37 cmarble Exp $
+ * $Id: class.ParserTest.php,v 1.5 2005/06/12 13:44:30 cmarble Exp $
  *
  * This file is part of coWiki. coWiki is free software under the terms of
  * the GNU General Public License (GPL). Read the LICENSE file. If you did
@@ -16,7 +16,7 @@
  * @author      Paul Hanchett <[email protected]>
  * @copyright   (C) Paul Hanchett, 2005
  * @license     http://www.gnu.org/licenses/gpl.html
- * @version     $Revision: 1.4 $
+ * @version     $Revision: 1.5 $
  *
  */
 
@@ -725,6 +725,16 @@
         ParserGreedyTagFormattingTest :: __construct($name, "Rem", "<rem>", "</rem>", '<rem>', "</rem>");
     }
 }
+//--------------------------------------------------------------------------
+//      <code>: Code-formatting tag for text within a paragraph
+//--------------------------------------------------------------------------
+class ParserCodeTagFormattingTest extends ParserGreedyTagFormattingTest
+{
+    function __construct($name)
+    {
+        ParserGreedyTagFormattingTest :: __construct($name, "Code", "<code>", "</code>", '<code>', "</code>", "<b>", "</b>", '<b origin="html">', '</b>' );
+    }
+}
 
 //--------------------------------------------------------------------------
 //      Basic tests for formatting text within <tags> within paragraphs
@@ -946,16 +956,6 @@
     }
 }
 //--------------------------------------------------------------------------
-//      <code>: Code-formatting tag for text within a paragraph
-//--------------------------------------------------------------------------
-class ParserCodeTagFormattingTest extends ParserGreedyContentTagFormattingTest
-{
-    function __construct($name)
-    {
-        ParserGreedyContentTagFormattingTest :: __construct($name, "Code", "<code>", "</code>", '<code>', "</code>", "<b>", "</b>", '<b origin="html">', '</b>' );
-    }
-}
-//--------------------------------------------------------------------------
 //      <posting>: Posting-formatted tag for text within a paragraph
 //--------------------------------------------------------------------------
 class ParserPostingTagFormattingTest extends ParserGreedyContentTagFormattingTest {
@@ -1510,5 +1510,69 @@
         $this->assertEquals(trim($inputString), trim($this->r->parse($outputString)));
     }
 
+}
+
+//--------------------------------------------------------------------------
+//      Basic tests for formatting text within paragraphs
+//--------------------------------------------------------------------------
+class ParserBlockFormattingTest extends PHPUnit_TestCase
+{
+    var $p = nil;
+    var $r = nil;
+
+    //--------------------------------------------------------------
+    //  Standard constructor for unit tests.
+    //--------------------------------------------------------------
+    function __construct($name)
+    {
+        $this->PHPUnit_TestCase($name);
+    }
+
+    //--------------------------------------------------------------
+    //  Setup: Set up an instance of the parser for testing
+    //--------------------------------------------------------------
+    function setUp()
+    {
+        $this->p = TestWikiParser :: getInstance();
+        $this->r = TestReverseParser :: getInstance();
+    }
+
+    function testBlock() {
+        $inputString = <<<EOD
+<code>
+// An example of why tradition shared hosting is not secure
+
+copyr('/home/companya/', '/home/joeuser/www/stolenfiles');
+
+function copyr($source, $dest){
+    // Simple copy for a file
+    if (is_file($source)) {
+        return copy($source, $dest);
+    }
+    // Make destination directory
+    if (!is_dir($dest)) {
+        mkdir($dest);
+    }
+    // Loop through the folder
+    $dir = dir($source);
+    while (false !== $entry = $dir->read()) {
+        // Skip pointers
+        if ($entry == '.' || $entry == '..') {
+            continue;
+        }  
+      // Deep copy directories
+        if ($dest !== "$source/$entry") { 
+           copyr("$source/$entry", "$dest/$entry");
+        }
+    } 
+   // Clean up
+    $dir->close();
+    return true;}                 
+</code>
+EOD;
+        $outputString = "??";
+        $this->assertEquals($outputString, $this->p->parse($inputString));
+        //$this->assertEquals(trim($inputString),trim($this->r->parse($outputString)));
+    }
 }
 ?>