r98804 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r98803‎ | r98804 | r98805 >
Date:20:51, 3 October 2011
Author:preilly
Status:ok (Comments)
Tags:
Comment:
fix for bug 31310 - Mobile can deliver malformed WML content
Modified paths:
  • /trunk/extensions/MobileFrontend/MobileFrontend.php (modified) (history)
  • /trunk/extensions/MobileFrontend/views/layout/application.wml.php (modified) (history)

Diff [purge]

Index: trunk/extensions/MobileFrontend/MobileFrontend.php
@@ -803,7 +803,7 @@
804804 $segmentsCount = count( $segments );
805805 $card .= "<p>" . $idx . "/" . $segmentsCount . "</p>";
806806
807 - $useFormatParam = ( isset( self::$useFormat ) ) ? '&' . 'useformat=' . self::$useFormat : '';
 807+ $useFormatParam = ( isset( self::$useFormat ) ) ? '&amp;' . 'useformat=' . self::$useFormat : '';
808808
809809 // Title::getLocalUrl doesn't work at this point since PHP 5.1.x, all objects have their destructors called
810810 // before the output buffer callback function executes.
@@ -817,7 +817,7 @@
818818 $delimiter = ( !empty( $qs ) ) ? '?' : '';
819819 $basePageParts = wfParseUrl( self::$currentURL );
820820 $basePage = $basePageParts['scheme'] . $basePageParts['delimiter'] . $basePageParts['host'] . $basePageParts['path'] . $delimiter . $qs;
821 - $appendDelimiter = ( $delimiter === '?' ) ? '&' : '?';
 821+ $appendDelimiter = ( $delimiter === '?' ) ? '&amp;' : '?';
822822
823823 if ( $idx < $segmentsCount ) {
824824 $card .= "<p><a href=\"{$basePage}{$appendDelimiter}seg={$idx}{$useFormatParam}\">" . self::$messages['mobile-frontend-wml-continue'] . "</a></p>";
@@ -1032,6 +1032,12 @@
10331033 // Add segmentation markers
10341034 $contentHtml = $this->headingTransform( $contentHtml );
10351035
 1036+ // Content removal for WML rendering
 1037+ $elements = array( 'span', 'div', 'sup', 'h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'sup', 'sub' );
 1038+ foreach ( $elements as $element ) {
 1039+ $contentHtml = preg_replace( '#</?' . $element . '[^>]*>#is', '', $contentHtml );
 1040+ }
 1041+
10361042 // Content wrapping
10371043 $contentHtml = $this->createWMLCard( $contentHtml );
10381044 require( 'views/layout/application.wml.php' );
Index: trunk/extensions/MobileFrontend/views/layout/application.wml.php
@@ -6,13 +6,9 @@
77
88 $applicationHtml = <<<EOT
99 <?xml version='1.0' encoding='utf-8' ?>
10 - <!DOCTYPE wml PUBLIC "-//WAPFORUM//DTD WML 1.1//EN" "http://www.wapforum.org/DTD/wml_1.1.xml">
 10+ <!DOCTYPE wml PUBLIC "-//WAPFORUM//DTD WML 1.3//EN"
 11+ "http://www.wapforum.org/DTD/wml13.dtd">
1112 <wml xml:lang="{$code}" dir="{$dir}">
12 - <head>
13 - <meta name="ROBOTS" content="NOINDEX, NOFOLLOW" />
14 - <meta name="character-set=utf-8" content="charset"/>
15 - <meta forua="true" http-equiv="Cache-Control" content="max-age=0"/>
16 - </head>
1713 <template>
1814 <do name="home" type="options" label="{$homeButton}" >
1915 <go href="{$mainPageUrl}"/>

Follow-up revisions

RevisionCommit summaryAuthorDate
r98805mft r98804preilly20:55, 3 October 2011
r98806mft r98804preilly20:55, 3 October 2011

Comments

#Comment by Vigilius (talk | contribs)   03:14, 4 October 2011

should this be tagged 1.18? Has been merged into 1.18wmf

Status & tagging log