User:Jiangxin/BugFix
__NUMBERHEADINGS__
Bug 361: URL inside a URL breaks parsing
editBug 361: URL inside a URL breaks parsing
This testcase in parserTests.txt not passed in MediaWiki 1.5.2:
!! test External links: old URL-in-URL bug, mixed protocols !! input And again with mixed protocols: [ftp://example.com?url=http://example.com link] !! result <p>And again with mixed protocols: <a href="ftp://example.com?url=http://example.com" class='external text' title="ftp://example.com?url=http://example.com" rel="nofollow">link</a> </p> !!end
Fixed like this:
--- mediawiki-1.5.2/includes/Parser.php 2005-11-14 00:14:23.171875000 +0800 +++ mediawiki/includes/Parser.php 2005-11-13 17:32:23.562500000 +0800 @@ -1157,6 +1164,17 @@ while ( $i < count( $bits ) ){ $protocol = $bits[$i++]; $remainder = $bits[$i++]; + /* Fix BUG 361: URL within URL. (by johnson@worldhello.net) */ + while ( !preg_match('/[\s]+$/', $remainder) ) { + if( $i < count( $bits) ) + { + $remainder .= $bits[$i++]; + } + else + { + break; + } + } if ( preg_match( '/^('.EXT_LINK_URL_CLASS.'+)(.*)$/s', $remainder, $m ) ) { # Found some characters after the protocol that look promising
table_with_no_data
editThis testcase in parserTests.txt not passed in MediaWiki 1.5.2:
# This should not produce <table></table> as <table><tr><td></td></tr></table> # is the bare minimun required by the spec, see: # http://www.w3.org/TR/xhtml-modularization/dtd_module_defs.html#a_module_Basic_Tables !! test A table with no data. !! input {||} !! result !! end
Fixed like this:
--- mediawiki-1.5.2/includes/Parser.php 2005-11-14 00:16:44.359375000 +0800 +++ mediawiki/includes/Parser.php 2005-11-13 17:32:23.562500000 +0800 @@ -767,7 +767,14 @@ { if ( array_pop ( $td ) ) $t[] = '</td>' ; if ( array_pop ( $tr ) ) $t[] = '</tr>' ; - $t[] = '</table>' ; + if ( stristr($t[count($t)-1], "<table") ) + { + array_pop($t); + } + else + { + $t[] = '</table>' ; + } } $t = implode ( "\n" , $t ) ;
Texvc works under Windows
editfor MediaWiki 1.6.x
editIndex: includes/Math.php =================================================================== --- includes/Math.php (revision 51) +++ includes/Math.php (working copy) @@ -53,16 +53,35 @@ if( function_exists( 'is_executable' ) && !is_executable( $wgTexvc ) ) { return $this->_error( 'math_notexvc' ); } - $cmd = $wgTexvc . ' ' . - escapeshellarg( $wgTmpDirectory ).' '. - escapeshellarg( $wgTmpDirectory ).' '. - escapeshellarg( $this->tex ).' '. + + if ( wfIsWindows() ) { + $dict_dir_from = array("\\"); + $dict_dir_to = array("/"); + # NOTICE: escapeshellarg does not work in Windows/DOS prompt enviroment; + # DOS escape char is ^. Command "echo |" should write as "echo ^|", and "echo ^" should be "echo ^^" + $dict_math_from = array("^"); + $dict_math_to = array("^^"); + + $cmd = str_replace( $dict_dir_from, $dict_dir_to, $wgTexvc) . ' ' . + escapeshellarg( str_replace( $dict_dir_from, $dict_dir_to, $wgTmpDirectory ) ).' '. + escapeshellarg( str_replace( $dict_dir_from, $dict_dir_to, $wgTmpDirectory ) ).' '. + escapeshellarg( str_replace( $dict_math_from,$dict_math_to,$this->tex ) ).' '. escapeshellarg( $wgInputEncoding ); - if ( wfIsWindows() ) { # Invoke it within cygwin sh, because texvc expects sh features in its default shell - $cmd = 'sh -c ' . wfEscapeShellArg( $cmd ); + # Windows has a command convert.exe which conflict with ImageMagick's. So add a PATH definition before $cmd; + $cmd = "PATH=\"/sbin:/usr/sbin:/usr/local/sbin:/usr/local/bin:/usr/bin:/bin:/usr/X11R6/bin:\$PATH\"; " + .$cmd; + $cmd = 'sh -c ' . wfEscapeShellArg( $cmd ); } + else + { + $cmd = $wgTexvc . ' ' . + escapeshellarg( $wgTmpDirectory ).' '. + escapeshellarg( $wgTmpDirectory ).' '. + escapeshellarg( $this->tex ).' '. + escapeshellarg( $wgInputEncoding ); + } wfDebug( "TeX: $cmd\n" ); $contents = `$cmd`;
for MediaWiki 1.5.x
edit--- mediawiki-1.5.2/includes/Math.php 2005-11-13 17:00:37.234375000 +0800 +++ mediawiki/includes/Math.php 2005-11-13 17:32:23.328125000 +0800 @@ -60,15 +60,34 @@ if( function_exists( 'is_executable' ) && !is_executable( $wgTexvc ) ) { return $this->_error( 'math_notexvc' ); } - $cmd = $wgTexvc . ' ' . + + if ( wfIsWindows() ) { + $dict_dir_from = array("\\"); + $dict_dir_to = array("/"); + # NOTICE: escapeshellarg does not work in Windows/DOS prompt enviroment; + # DOS escape char is ^. Command "echo |" should write as "echo ^|", and "echo ^" should be "echo ^^" + $dict_math_from = array("^"); + $dict_math_to = array("^^"); + + $cmd = str_replace( $dict_dir_from, $dict_dir_to, $wgTexvc) . ' ' . + escapeshellarg( str_replace( $dict_dir_from, $dict_dir_to, $wgTmpDirectory ) ).' '. + escapeshellarg( str_replace( $dict_dir_from, $dict_dir_to, $wgMathDirectory ) ).' '. + escapeshellarg( str_replace( $dict_math_from,$dict_math_to,$this->tex ) ).' '. + escapeshellarg( $wgInputEncoding ); + + # Invoke it within cygwin sh, because texvc expects sh features in its default shell + # Windows has a command convert.exe which conflict with ImageMagick's. So add a PATH definition before $cmd; + $cmd = "PATH=\"/sbin:/usr/sbin:/usr/local/sbin:/usr/local/bin:/usr/bin:/bin:/usr/X11R6/bin:\$PATH\"; " + .$cmd; + $cmd = 'sh -c ' . wfEscapeShellArg( $cmd ); + } + else + { + $cmd = $wgTexvc . ' ' . escapeshellarg( $wgTmpDirectory ).' '. escapeshellarg( $wgMathDirectory ).' '. escapeshellarg( $this->tex ).' '. - escapeshellarg( $wgInputEncoding ); - - if ( wfIsWindows() ) { - # Invoke it within cygwin sh, because texvc expects sh features in its default shell - $cmd = 'sh -c ' . wfEscapeShellArg( $cmd ); + escapeshellarg( $wgInputEncoding ); } wfDebug( "TeX: $cmd\n" );
SpecialPage order by key
editIn my chinese translation wiki, I don't like the way what SpecialSpecialpage shows.
--- mediawiki-1.5.2/includes/SpecialSpecialpages.php 2005-11-13 17:00:37.937500000 +0800 +++ mediawiki/includes/SpecialSpecialpages.php 2005-11-13 17:32:24.234375000 +0800 @@ -58,7 +58,7 @@ /** Sort */ if ( $wgSortSpecialPages ) { - ksort( $sortedPages ); + asort( $sortedPages ); } /** Now output the HTML */
list without listitems
editSynopsis List without real content means a line begins with "*","#",":", but nothing else. like
*subitem has no content *****
It will be badly rendered.
- subitem has no content
Bugfix:
Index: maintenance/parserTests.txt
===================================================================
RCS file: /user/jiangxin/project/wiki/mediawiki/src/maintenance/parserTests.txt,v
retrieving revision 1.11
diff -u -r1.11 parserTests.txt
--- maintenance/parserTests.txt 17 Nov 2005 08:51:25 -0000 1.11
+++ maintenance/parserTests.txt 26 Nov 2005 14:37:39 -0000
@@ -35,6 +35,63 @@
###
!! test
+list without title, 1
+!! input
+#item
+##subitem1
+##
+##subitem3
+######
+!! result
+<ol><li>item
+<ol><li>subitem1
+</li><li>subitem3
+</li></ol>
+</li></ol>
+
+!! end
+
+!! test
+list without title, 2
+!! input
+######
+!! result
+!! end
+
+
+!! test
+list without title, 3
+!! input
+*item
+**
+**subitem2
+**subitem3
+*******
+
+#item
+##subitem1
+##
+##subitem3
+######
+
+end.
+!! result
+<ul><li>item
+<ul><li>subitem2
+</li><li>subitem3
+</li></ul>
+</li></ul>
+<ol><li>item
+<ol><li>subitem1
+</li><li>subitem3
+</li></ol>
+</li></ol>
+<p>end.
+</p>
+!! end
+
+
+!! test
indent <pre> block test
!! input
#indent <pre> block
Index: includes/Parser.php
===================================================================
RCS file: /user/jiangxin/project/wiki/mediawiki/src/includes/Parser.php,v
retrieving revision 1.17
diff -u -r1.17 Parser.php
--- includes/Parser.php 25 Nov 2005 14:48:11 -0000 1.17
+++ includes/Parser.php 26 Nov 2005 14:38:20 -0000
@@ -1754,6 +1754,10 @@
# Bugfix 1115, 1581(3989): Newline as list item terminator is troublesome, by JiangXin (http://www.worldhello.net).
if ( $prefixLength > 0 ) {
+ if ( strlen($oLine) == $prefixLength ) {
+ $prefixLength = isset($pref2)? strlen($pref2) : 0;
+ continue;
+ }
$firstline = true;
$in_pre = false;
for($i++; $oLine2 = $textLines[$i], $i < count($textLines); $i++) {
add default parameter support for Template (Mediawiki 1.6 may already support)
editusage: See test cases in Index: maintenance/parserTests.txt in the following differs.
code:
Index: includes/Parser.php =================================================================== RCS file: /user/jiangxin/project/wiki/mediawiki/src/includes/Parser.php,v retrieving revision 1.19 diff -u -r1.19 Parser.php --- includes/Parser.php 26 Nov 2005 14:40:35 -0000 1.19 +++ includes/Parser.php 27 Nov 2005 06:44:27 -0000 @@ -2092,7 +2092,7 @@ if ( $this->mOutputType == OT_HTML || $this->mOutputType == OT_WIKI ) { # Argument substitution - $text = preg_replace_callback( "/{{{([$titleChars]*?)}}}/", array( &$this, 'argSubstitution' ), $text ); + $text = preg_replace_callback( "/{{{([$titleChars]*?)(?:(?:\|)([$titleChars]*))?}}}/", array( &$this, 'argSubstitution' ), $text ); } # Template substitution $regex = '/(\\n|{)?{{(['.$titleChars.']*)(\\|.*?|)}}/s'; @@ -2534,7 +2534,16 @@ $inputArgs = end( $this->mArgStack ); if ( array_key_exists( $arg, $inputArgs ) ) { - $text = $inputArgs[$arg]; + if ( empty($inputArgs[$arg]) ) + { + if ( isset($matches[2]) ) { + $text = $matches[2]; + } else { + $text = $inputArgs[$arg]; + } + } else { + $text = $inputArgs[$arg]; + } } return $text; Index: maintenance/parserTests.txt =================================================================== RCS file: /user/jiangxin/project/wiki/mediawiki/src/maintenance/parserTests.txt,v retrieving revision 1.12 diff -u -r1.12 parserTests.txt --- maintenance/parserTests.txt 26 Nov 2005 14:40:35 -0000 1.12 +++ maintenance/parserTests.txt 27 Nov 2005 06:44:32 -0000 @@ -443,6 +443,40 @@ </p> !! end +!! article +Template:param_with_default_test +!! text +This is a test template with parameter. +* arg1: {{{1}}} +* arg2: {{{2|arg2 has this default value}}} +* arg3: {{{3|arg3 has this default value}}} +* name: {{{name|r u jiangxin?}}} +* gender: {{{gender|girl or boy?}}} +* age: {{{age|put your age here...}}} +* job: {{{job}}} +* salary: {{{salary}}} + +!! endarticle + +!! test +Template param_with_default_test +!! input +{{param_with_default_test|hi|2=|name=|age=MyAge|salary=Not tell you}} +!! result +<p>This is a test template with parameter. +</p> +<ul><li> arg1: hi +</li><li> arg2: arg2 has this default value +</li><li> arg3: {{{3|arg3 has this default value}}} +</li><li> name: r u jiangxin? +</li><li> gender: {{{gender|girl or boy?}}} +</li><li> age: MyAge +</li><li> job: {{{job}}} +</li><li> salary: Not tell you +</li></ul> + +!! end + ### ### Basic tests