r114594 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r114593‎ | r114594 | r114595 >
Date:08:40, 29 March 2012
Author:ning
Status:new
Tags:
Comment:
bug fix, table cell contains html tag, fullurl magic word as link
Modified paths:
  • /trunk/extensions/WikiObjectModel/includes/models/WOM_OM_Link.php (modified) (history)
  • /trunk/extensions/WikiObjectModel/includes/models/WOM_OM_NestProperty.php (modified) (history)
  • /trunk/extensions/WikiObjectModel/includes/parsers/WOMLinkParser.php (modified) (history)
  • /trunk/extensions/WikiObjectModel/includes/parsers/WOMTblCellParser.php (modified) (history)

Diff [purge]

Index: trunk/extensions/WikiObjectModel/includes/parsers/WOMLinkParser.php
@@ -28,6 +28,11 @@
2929 if ( $r ) {
3030 return array( 'len' => strlen( $m[0] ), 'obj' => new WOMLinkModel( $m[1], isset( $m[3] ) ? $m[3] : '' ) );
3131 }
 32+ // FIXME: hardcode here, for fullurl magic word
 33+ $r = preg_match( '/^\[(\{\{fullurl:[^}]+\}\})(\s+([^\]]+))?\]/i', $text, $m );
 34+ if ( $r ) {
 35+ return array( 'len' => strlen( $m[0] ), 'obj' => new WOMLinkModel( $m[1], isset( $m[3] ) ? $m[3] : '' ) );
 36+ }
3237 // includes/Parser.php Parser->doMagicLinks
3338 $r = preg_match( '/^(?:' . wfUrlProtocols() . ')[^][<>"|}{\\x00-\\x20\\x7F]+/', $text, $m );
3439 if ( $r ) {
Index: trunk/extensions/WikiObjectModel/includes/parsers/WOMTblCellParser.php
@@ -48,7 +48,7 @@
4949
5050 $len = strlen( $m[0] );
5151 $text = substr( $text, $len );
52 - $r = preg_match( '/^([^\n|]*\|)[^|]/', $text, $m1 );
 52+ $r = preg_match( '/^([^<\n|]*\|)[^|]/', $text, $m1 );
5353 if ( !$r || preg_match( '/\{\{/', $m1[1] ) ) {
5454 // FIXME: what if matched style contains '{{', just think it is table body
5555 return array( 'len' => $len, 'obj' => new WOMTableCellModel( $m[0] ) );
Index: trunk/extensions/WikiObjectModel/includes/models/WOM_OM_NestProperty.php
@@ -54,14 +54,14 @@
5555 }
5656 return implode( '|', $text );
5757 }
58 -
 58+
5959 public function getPropertyValue() {
6060 if ( count ( $this->m_objects ) > 0 )
6161 return $this->m_objects[0]->getWikiText();
6262
6363 return '';
6464 }
65 -
 65+
6666 public function getCaption() {
6767 $text = array();
6868 $first = true;
@@ -74,7 +74,7 @@
7575 }
7676 return implode( '|', $text );
7777 }
78 -
 78+
7979 public function setXMLAttribute( $key, $value ) {
8080 if ( $value == '' ) throw new MWException( __METHOD__ . ": value cannot be empty" );
8181
Index: trunk/extensions/WikiObjectModel/includes/models/WOM_OM_Link.php
@@ -22,6 +22,9 @@
2323 if ( preg_match( '/^(?:' . wfUrlProtocols() . ')[^][<>"\\x00-\\x20\\x7F]+/', $this->m_link ) )
2424 return false;
2525
 26+ if ( preg_match( '/^\{\{fullurl:/i', $this->m_link ) )
 27+ return false;
 28+
2629 return true;
2730 }
2831 public function getLink() {