CVS update: /cowiki/includes/cowiki/class/parse/
[email protected] 26 Jul 2005 16:06:44 -0000
| Newsgroups | gmane.comp.php.cowiki.cvs |
|---|---|
| Message-ID | <[email protected]> |
User: cmarble Date: 2005/07/26 09:06:44 Modified: cowiki/includes/cowiki/class/parse/class.WikiParser.php Log: Issue number: 233 Misformed links (essentially collections of (()) and [[]]) are ignored by the parser (recognised as text, not link) in such a way as to retain correct performance of the unit tests. Also, no more hanging during a parse - if the parser finds it is repeating itself, it will bomb with an error message. 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.55&r2=1.56 Delta lines: +19 -9 -------------------- --- class.WikiParser.php 22 Jun 2005 17:12:47 -0000 1.55 +++ class.WikiParser.php 26 Jul 2005 16:06:41 -0000 1.56 @@ -2,7 +2,7 @@ /** * - * $Id: class.WikiParser.php,v 1.55 2005/06/22 17:12:47 cmarble Exp $ + * $Id: class.WikiParser.php,v 1.56 2005/07/26 16:06:41 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.55 $ + * @version $Revision: 1.56 $ * */ @@ -369,6 +369,7 @@ $sStr = ltrim( $sStr ); $debug = false; + $lastStr = $sStr; if($debug){echo "processContent ".$sStr."\n";} while( $sStr != '' ) { //paragraphs @@ -446,28 +447,28 @@ '([^\(\)]+\)\([^\(\)]+)'. '\)\)=Usx', $sStr, $aMatches )) { - if($debug){echo "6\n";} + if($debug){echo "6a\n";} $sRet .= $this->createLinkElement( $aMatches[1], "round" ); //links [[][]] }else if( preg_match( '=^\[\['. '([^\[\]]+\]\[[^\[\]]+)'. '\]\]=Usx', $sStr, $aMatches )) { - if($debug){echo "7\n";} + if($debug){echo "7a ".$aMatches[1]."\n";} $sRet .= $this->createLinkElement( $aMatches[1], "square" ); //links (()) }else if( preg_match( '=^\(\('. '([^\(\)]+)'. '\)\)=Usx', $sStr, $aMatches )) { - if($debug){echo "6\n";} + if($debug){echo "6b\n";} $sRet .= $this->createLinkElement( $aMatches[1], "round" ); //links [[]] }else if( preg_match( '=^\[\['. '([^\[\]]+)'. '\]\]=Usx', $sStr, $aMatches )) { - if($debug){echo "7\n";} + if($debug){echo "7b ".$aMatches[1]."\n";} $sRet .= $this->createLinkElement( $aMatches[1], "square" ); }else if( preg_match( '=^\(\(?[^\(\)]+\)?=Ui', $sStr, $aMatches )) { if($debug){echo "8\n";} @@ -478,11 +479,12 @@ }else if( preg_match( '=^[^\(\)]+\)\([^\(\)]+=Ui', $sStr, $aMatches )) { if($debug){echo "10\n";} $sRet .= $aMatches[0]; - /* - }else if( preg_match( '=^\([^\(\)]+\)=Ui', $sStr, $aMatches )) { + }else if( preg_match( '=^[\(\[]+=Ui', $sStr, $aMatches )) { if($debug){echo "10.5\n";} $sRet .= $aMatches[0]; - */ + }else if( preg_match( '=^[\)\]]+=Ui', $sStr, $aMatches )) { + if($debug){echo "10.6\n";} + $sRet .= $aMatches[0]; //WikiWords }else if( preg_match( '=^([A-Z][a-z]+([A-Z][a-z]+)+)=s', $sStr, $aMatches )) { @@ -646,6 +648,14 @@ if($debug){echo $sStr."\n";} if( isset($aMatches[0]) ) { $sStr = substr( $sStr, strlen($aMatches[0]) ); + } + if( $lastStr == $sStr ) { + $msg = "Parse failed before ".$sStr."\n"; + $sRet .= $msg; + echo $msg; + break; + } else { + $lastStr = $sStr; } } //process emphasis tokens