Index: trunk/extensions/EtherpadLite/EtherpadLite.php |
— | — | @@ -64,7 +64,7 @@ |
65 | 65 | 'path' => __FILE__, |
66 | 66 | 'name' => 'EtherpadLite', |
67 | 67 | 'author' => array( 'Thomas Gries' ), |
68 | | - 'version' => '1.08 20120215', |
| 68 | + 'version' => '1.09 20120218', |
69 | 69 | 'url' => 'https://www.mediawiki.org/wiki/Extension:EtherpadLite', |
70 | 70 | 'descriptionmsg' => 'etherpadlite-desc', |
71 | 71 | ); |
— | — | @@ -97,14 +97,16 @@ |
98 | 98 | # may be a security concern. |
99 | 99 | # |
100 | 100 | # 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. |
102 | 102 | $wgEtherpadLiteUrlWhitelist = array(); |
103 | 103 | # |
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) |
105 | 105 | # $wgEtherpadLiteUrlWhitelist = array( "*" ); |
106 | 106 | |
107 | 107 | # https://www.mediawiki.org/wiki/Manual:Tag_extensions |
108 | 108 | function wfEtherpadLiteParserInit( $parser ) { |
| 109 | + global $wgEtherpadLitePadsOnThisPage; |
| 110 | + $wgEtherpadLitePadsOnThisPage = array(); |
109 | 111 | $parser->setHook('eplite', 'wfEtherpadLiteRender'); |
110 | 112 | return true; |
111 | 113 | } |
— | — | @@ -114,7 +116,8 @@ |
115 | 117 | global $wgUser; |
116 | 118 | global $wgEtherpadLiteDefaultPadUrl, $wgEtherpadLiteDefaultWidth, $wgEtherpadLiteDefaultHeight, |
117 | 119 | $wgEtherpadLiteMonospacedFont, $wgEtherpadLiteShowControls, $wgEtherpadLiteShowLineNumbers, |
118 | | - $wgEtherpadLiteShowChat, $wgEtherpadLiteShowAuthorColors, $wgEtherpadLiteUrlWhitelist; |
| 120 | + $wgEtherpadLiteShowChat, $wgEtherpadLiteShowAuthorColors, $wgEtherpadLiteUrlWhitelist, |
| 121 | + $wgEtherpadLitePadsOnThisPage; |
119 | 122 | |
120 | 123 | # check the user input |
121 | 124 | |
— | — | @@ -181,6 +184,18 @@ |
182 | 185 | # Append the id to end of url. Strip off trailing / if present before appending one. |
183 | 186 | $url = preg_replace( "/\/+$/", "", $src ) . "/" . $args['id']; |
184 | 187 | |
| 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 | + |
185 | 200 | |
186 | 201 | # preset the pad username from MediaWiki username or IP |
187 | 202 | # this not strict, as the pad username can be overwritten in the pad |
Index: trunk/extensions/EtherpadLite/EtherpadLite.i18n.php |
— | — | @@ -16,12 +16,14 @@ |
17 | 17 | 'etherpadlite-invalid-pad-url' => '"$1" is not a valid Etherpad Lite URL or pad name.', |
18 | 18 | '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}}.', |
19 | 19 | '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.', |
20 | 21 | ); |
21 | 22 | |
22 | 23 | /** Message documentation (Message documentation) */ |
23 | 24 | $messages['qqq'] = array( |
24 | 25 | '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", |
25 | 26 | '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.', |
26 | 28 | ); |
27 | 29 | |
28 | 30 | /** Belarusian (Taraškievica orthography) (Беларуская (тарашкевіца)) |