r24815 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r24814‎ | r24815 | r24816 >
Date:11:45, 15 August 2007
Author:nhuffschmid
Status:old
Tags:
Comment:
fixed link parser
Modified paths:
  • /trunk/wap/hawiki/hawiki_parser_hawpedia.inc (modified) (history)

Diff [purge]

Index: trunk/wap/hawiki/hawiki_parser_hawpedia.inc
@@ -1,7 +1,7 @@
22 <?php
33 /*
44 * hawiki parser for hawpedia
5 - * $Date: 2007/04/01 23:20:25 $
 5+ * $Date$
66 */
77
88 function namespace_regex1($namespace_name /* english string */ , $separator='/')
@@ -90,19 +90,29 @@
9191 }
9292
9393 #if (preg_match("/^\[\[([^\[\]]+)\]\]/", $input, $matches))
94 - // this breaks the parser and creates "invalid wiki syntax" errors!
95 - // reactivated old HawPedia regex:
96 - if (preg_match("/^\[\[(([^\[\]]+)|(\[[^\[\]]*\])*|(\[\[[^\[\]]*\]\])*)+\]\]/", $input, $matches))
 94+ // this MediaWiki regex breaks the parser and creates "invalid wiki syntax" errors!
 95+ #if (preg_match("/^\[\[(([^\[\]]+)|(\[[^\[\]]*\])*|(\[\[[^\[\]]*\]\])*)+\]\]/", $input, $matches))
 96+ // this old HawPedia regex does not work from php 5.2 onward!
 97+ if (preg_match("/^\[\[/", $input))
9798 {
9899 // Forced WikiName ((a_page_with_any_name))
99100
100101 // images can be nested like this: [[Image:...|[[link]]...]]
101102 // or this: [[Image:...|[link]...]]
102 - # echo('<blockquote>'); print_r($matches); echo('</blockquote>');
103 - $input = substr($input, strlen($matches[0]));
 103+
 104+ // find closing brackets ...
 105+ $bracket_level = 2;
 106+ for ($pos = 2; $bracket_level > 0; $pos++) {
 107+ if (substr($input, $pos, 1) == '[')
 108+ $bracket_level++;
104109
105 - $wikipage = substr($matches[0], 2, -2);
106 -
 110+ if (substr($input, $pos, 1) == ']')
 111+ $bracket_level--;
 112+ }
 113+
 114+ $wikipage = substr($input, 2, $pos-4);
 115+ $input = substr($input, $pos);
 116+
107117 $po["extwiki"] = ""; // hawpedia supports no external wikis
108118
109119 $link = explode("|", $wikipage); // test for alternative link label
Property changes on: trunk/wap/hawiki/hawiki_parser_hawpedia.inc
___________________________________________________________________
Added: svn:keywords
110120 + LastChangedDate

Status & tagging log