https://www.mediawiki.org/wiki/Special:Code/MediaWiki/111839
Revision: 111839
Author: wikinaut
Date: 2012-02-18 19:32:20 +0000 (Sat, 18 Feb 2012)
Log Message:
-----------
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
trunk/extensions/EtherpadLite/EtherpadLite.php
Modified: trunk/extensions/EtherpadLite/EtherpadLite.i18n.php
===================================================================
--- trunk/extensions/EtherpadLite/EtherpadLite.i18n.php 2012-02-18 18:54:12 UTC
(rev 111838)
+++ trunk/extensions/EtherpadLite/EtherpadLite.i18n.php 2012-02-18 19:32:20 UTC
(rev 111839)
@@ -16,12 +16,14 @@
'etherpadlite-invalid-pad-url' => '"$1" is not a valid Etherpad Lite
URL or pad name.',
'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}}.',
'etherpadlite-empty-whitelist' => '"$1" is not in the whitelist of
allowed Etherpad Lite servers. There are no allowed servers in the whitelist.',
+ '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.',
);
/** Message documentation (Message documentation) */
$messages['qqq'] = array(
'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",
'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",
+ '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.',
);
/** Belarusian (Taraškievica orthography) (Беларуская (тарашкевіца))
Modified: trunk/extensions/EtherpadLite/EtherpadLite.php
===================================================================
--- trunk/extensions/EtherpadLite/EtherpadLite.php 2012-02-18 18:54:12 UTC
(rev 111838)
+++ trunk/extensions/EtherpadLite/EtherpadLite.php 2012-02-18 19:32:20 UTC
(rev 111839)
@@ -64,7 +64,7 @@
'path' => __FILE__,
'name' => 'EtherpadLite',
'author' => array( 'Thomas Gries' ),
- 'version' => '1.08 20120215',
+ 'version' => '1.09 20120218',
'url' => 'https://www.mediawiki.org/wiki/Extension:EtherpadLite',
'descriptionmsg' => 'etherpadlite-desc',
);
@@ -97,14 +97,16 @@
# may be a security concern.
#
# an empty or non-existent array means: no whitelist defined
-# this is the default: an empty whitelist
+# this is the default: an empty whitelist. No servers are allowed by default.
$wgEtherpadLiteUrlWhitelist = array();
#
-# include "*" if you expressly want to allow all urls
+# include "*" if you expressly want to allow all urls (you should not do this)
# $wgEtherpadLiteUrlWhitelist = array( "*" );
# https://www.mediawiki.org/wiki/Manual:Tag_extensions
function wfEtherpadLiteParserInit( $parser ) {
+ global $wgEtherpadLitePadsOnThisPage;
+ $wgEtherpadLitePadsOnThisPage = array();
$parser->setHook('eplite', 'wfEtherpadLiteRender');
return true;
}
@@ -114,7 +116,8 @@
global $wgUser;
global $wgEtherpadLiteDefaultPadUrl, $wgEtherpadLiteDefaultWidth,
$wgEtherpadLiteDefaultHeight,
$wgEtherpadLiteMonospacedFont, $wgEtherpadLiteShowControls,
$wgEtherpadLiteShowLineNumbers,
- $wgEtherpadLiteShowChat, $wgEtherpadLiteShowAuthorColors,
$wgEtherpadLiteUrlWhitelist;
+ $wgEtherpadLiteShowChat, $wgEtherpadLiteShowAuthorColors,
$wgEtherpadLiteUrlWhitelist,
+ $wgEtherpadLitePadsOnThisPage;
# check the user input
@@ -181,6 +184,18 @@
# Append the id to end of url. Strip off trailing / if present before
appending one.
$url = preg_replace( "/\/+$/", "", $src ) . "/" . $args['id'];
+ # prevent multiple iframes and rendering of a same pad on a page
+ # show an error message if a pad is found more than once on a page.
+ #
+ # the empty id however may be used more than once as the empty id
invokes an
+ # Etherpad Lite server showing its "create a pad" html page.
+
+ if ( !in_array( $url, $wgEtherpadLitePadsOnThisPage ) ) {
+ $wgEtherpadLitePadsOnThisPage[] = $url;
+ } elseif ( $args['id'] !== "" ) {
+ return wfEtherpadLiteError(
'etherpadlite-pad-used-more-than-once', $url );
+ }
+
# preset the pad username from MediaWiki username or IP
# this not strict, as the pad username can be overwritten in the pad
_______________________________________________
MediaWiki-CVS mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs