r111839 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r111838‎ | r111839 | r111840 >
Date:19:32, 18 February 2012
Author:wikinaut
Status:deferred
Tags:
Comment:
prevent to render multiple same pads on a page for several reasons (performance degradation; Etherpad Lite bug of non-unique ids in DOM elements). Store per current page the used pad urls = server/padid and show an error message and the pad url if a pad url is used another time on the current page.
Modified paths:
  • /trunk/extensions/EtherpadLite/EtherpadLite.i18n.php (modified) (history)
  • /trunk/extensions/EtherpadLite/EtherpadLite.php (modified) (history)

Diff [purge]

Index: trunk/extensions/EtherpadLite/EtherpadLite.php
@@ -64,7 +64,7 @@
6565 'path' => __FILE__,
6666 'name' => 'EtherpadLite',
6767 'author' => array( 'Thomas Gries' ),
68 - 'version' => '1.08 20120215',
 68+ 'version' => '1.09 20120218',
6969 'url' => 'https://www.mediawiki.org/wiki/Extension:EtherpadLite',
7070 'descriptionmsg' => 'etherpadlite-desc',
7171 );
@@ -97,14 +97,16 @@
9898 # may be a security concern.
9999 #
100100 # an empty or non-existent array means: no whitelist defined
101 -# this is the default: an empty whitelist
 101+# this is the default: an empty whitelist. No servers are allowed by default.
102102 $wgEtherpadLiteUrlWhitelist = array();
103103 #
104 -# include "*" if you expressly want to allow all urls
 104+# include "*" if you expressly want to allow all urls (you should not do this)
105105 # $wgEtherpadLiteUrlWhitelist = array( "*" );
106106
107107 # https://www.mediawiki.org/wiki/Manual:Tag_extensions
108108 function wfEtherpadLiteParserInit( $parser ) {
 109+ global $wgEtherpadLitePadsOnThisPage;
 110+ $wgEtherpadLitePadsOnThisPage = array();
109111 $parser->setHook('eplite', 'wfEtherpadLiteRender');
110112 return true;
111113 }
@@ -114,7 +116,8 @@
115117 global $wgUser;
116118 global $wgEtherpadLiteDefaultPadUrl, $wgEtherpadLiteDefaultWidth, $wgEtherpadLiteDefaultHeight,
117119 $wgEtherpadLiteMonospacedFont, $wgEtherpadLiteShowControls, $wgEtherpadLiteShowLineNumbers,
118 - $wgEtherpadLiteShowChat, $wgEtherpadLiteShowAuthorColors, $wgEtherpadLiteUrlWhitelist;
 120+ $wgEtherpadLiteShowChat, $wgEtherpadLiteShowAuthorColors, $wgEtherpadLiteUrlWhitelist,
 121+ $wgEtherpadLitePadsOnThisPage;
119122
120123 # check the user input
121124
@@ -181,6 +184,18 @@
182185 # Append the id to end of url. Strip off trailing / if present before appending one.
183186 $url = preg_replace( "/\/+$/", "", $src ) . "/" . $args['id'];
184187
 188+ # prevent multiple iframes and rendering of a same pad on a page
 189+ # show an error message if a pad is found more than once on a page.
 190+ #
 191+ # the empty id however may be used more than once as the empty id invokes an
 192+ # Etherpad Lite server showing its "create a pad" html page.
 193+
 194+ if ( !in_array( $url, $wgEtherpadLitePadsOnThisPage ) ) {
 195+ $wgEtherpadLitePadsOnThisPage[] = $url;
 196+ } elseif ( $args['id'] !== "" ) {
 197+ return wfEtherpadLiteError( 'etherpadlite-pad-used-more-than-once', $url );
 198+ }
 199+
185200
186201 # preset the pad username from MediaWiki username or IP
187202 # this not strict, as the pad username can be overwritten in the pad
Index: trunk/extensions/EtherpadLite/EtherpadLite.i18n.php
@@ -16,12 +16,14 @@
1717 'etherpadlite-invalid-pad-url' => '"$1" is not a valid Etherpad Lite URL or pad name.',
1818 'etherpadlite-url-is-not-whitelisted' => '"$1" is not in the whitelist of allowed Etherpad Lite servers. {{PLURAL:$3|$2 is the only allowed server|The allowed servers are as follows: $2}}.',
1919 'etherpadlite-empty-whitelist' => '"$1" is not in the whitelist of allowed Etherpad Lite servers. There are no allowed servers in the whitelist.',
 20+ 'etherpadlite-pad-used-more-than-once' => 'The pad "$1" has already been used before on this page; you can have many pads on a page, but only if they are different pads.',
2021 );
2122
2223 /** Message documentation (Message documentation) */
2324 $messages['qqq'] = array(
2425 'etherpadlite-invalid-pad-url' => "Error if the url did not meet validation (for example, if it didn't start with an allowed protocol). $1 is the invalid url",
2526 'etherpadlite-url-is-not-whitelisted' => "Error if url isn't in list of allowed urls. $1 is name of url specified by user, $2 is a comma separated list of allowed urls, $3 is the number of urls in the allowed list",
 27+ 'etherpadlite-pad-used-more-than-once' => 'Error if users try to show multiple frames of the very same pad, identified by the full pad url $1 (server/padid). Each pad must be unique on a wiki page.',
2628 );
2729
2830 /** Belarusian (Taraškievica orthography) (‪Беларуская (тарашкевіца)‬)

Status & tagging log