r57707 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r57706‎ | r57707 | r57708 >
Date:18:15, 14 October 2009
Author:catrope
Status:ok
Tags:
Comment:
EditToolbar:
* (bug 21104) Link dialog should validate URLs better
* (bug 21110) Search&replace triggers replace on Enter after closing dialog
* (bug 21112) Search&replace makes browser barf on invalid regex
* Add class="wikitable" to CGD-generated tables as well
Modified paths:
  • /trunk/extensions/UsabilityInitiative/EditToolbar/EditToolbar.hooks.php (modified) (history)
  • /trunk/extensions/UsabilityInitiative/EditToolbar/EditToolbar.i18n.php (modified) (history)
  • /trunk/extensions/UsabilityInitiative/EditToolbar/EditToolbar.js (modified) (history)
  • /trunk/extensions/UsabilityInitiative/EditToolbar/EditToolbar.php (modified) (history)

Diff [purge]

Index: trunk/extensions/UsabilityInitiative/EditToolbar/EditToolbar.hooks.php
@@ -121,6 +121,7 @@
122122 'edittoolbar-tool-replace-nomatch',
123123 'edittoolbar-tool-replace-success',
124124 'edittoolbar-tool-replace-emptysearch',
 125+ 'edittoolbar-tool-replace-invalidregex',
125126 /* Special Characters Section */
126127 'edittoolbar-section-characters',
127128 'edittoolbar-characters-page-latin',
Index: trunk/extensions/UsabilityInitiative/EditToolbar/EditToolbar.js
@@ -985,9 +985,8 @@
986986 var escTarget = escapeExternalTarget( target );
987987 var escText = escapeExternalText( text );
988988 whitespace = $j( '#edittoolbar-link-dialog-tab-ext' ).data( 'whitespace' );
989 - if ( target == '' || target == 'http://' ) {
 989+ if ( !target.match( /^[a-z]+:\/\/./ ) ) {
990990 // Refuse to add links to invalid URLs
991 - // TODO: More elaborate regex here?
992991 alert( gM( 'edittoolbar-tool-link-ext-invalid' ) );
993992 return;
994993 }
@@ -1142,7 +1141,7 @@
11431142 {
11441143 type: 'replace',
11451144 options: {
1146 - pre: "{|\n",
 1145+ pre: "{| class=\"wikitable\"\n",
11471146 peri: table,
11481147 post: "|}",
11491148 ownline: true
@@ -1182,6 +1181,7 @@
11831182 <div id="edittoolbar-replace-nomatch" rel="edittoolbar-tool-replace-nomatch"></div>\
11841183 <div id="edittoolbar-replace-success"></div>\
11851184 <div id="edittoolbar-replace-emptysearch" rel="edittoolbar-tool-replace-emptysearch"></div>\
 1185+ <div id="edittoolbar-replace-invalidregex"></div>\
11861186 </div>\
11871187 <fieldset><table><tr>\
11881188 <td><label for="edittoolbar-replace-search" rel="edittoolbar-tool-replace-search"></label></td>\
@@ -1203,7 +1203,7 @@
12041204
12051205 // TODO: Find a cleaner way to share this function
12061206 $j(this).data( 'replaceCallback', function( mode ) {
1207 - $j( '#edittoolbar-replace-nomatch, #edittoolbar-replace-success, #edittoolbar-replace-emptysearch' ).hide();
 1207+ $j( '#edittoolbar-replace-nomatch, #edittoolbar-replace-success, #edittoolbar-replace-emptysearch, #edittoolbar-replace-invalidregex' ).hide();
12081208 var searchStr = $j( '#edittoolbar-replace-search' ).val();
12091209 if ( searchStr == '' ) {
12101210 $j( '#edittoolbar-replace-emptysearch' ).show();
@@ -1222,7 +1222,15 @@
12231223 if ( !isRegex ) {
12241224 searchStr = RegExp.escape( searchStr );
12251225 }
1226 - var regex = new RegExp( searchStr, flags );
 1226+ try {
 1227+ var regex = new RegExp( searchStr, flags );
 1228+ } catch( e ) {
 1229+ $j( '#edittoolbar-replace-invalidregex' )
 1230+ .text( gM( 'edittoolbar-tool-replace-invalidregex',
 1231+ e.message ) )
 1232+ .show();
 1233+ return;
 1234+ }
12271235 var $textarea = $j(this).data( 'context' ).$textarea;
12281236 var text = $j.wikiEditor.fixOperaBrokenness( $textarea.val() );
12291237 var matches = false;
@@ -1288,16 +1296,12 @@
12891297 },
12901298 'edittoolbar-tool-replace-close': function() {
12911299 $j(this).dialog( 'close' );
1292 - $j(this).data( 'context' ).$textarea
1293 - .unbind( 'keypress.srdialog' )
1294 - .focus();
1295 - $j(this).closest( '.ui-dialog' ).data( 'dialogaction', false );
12961300 }
12971301 },
12981302 open: function() {
12991303 $j(this).data( 'offset', 0 );
13001304 $j( '#edittoolbar-replace-search' ).focus();
1301 - $j( '#edittoolbar-replace-nomatch, #edittoolbar-replace-success, #edittoolbar-replace-emptysearch' ).hide();
 1305+ $j( '#edittoolbar-replace-nomatch, #edittoolbar-replace-success, #edittoolbar-replace-emptysearch, #edittoolbar-replace-invalidregex' ).hide();
13021306 if ( !( $j(this).data( 'dialogkeypressset' ) ) ) {
13031307 $j(this).data( 'dialogkeypressset', true );
13041308 // Execute the action associated with the first button
@@ -1318,6 +1322,12 @@
13191323 e.preventDefault();
13201324 }
13211325 });
 1326+ },
 1327+ close: function() {
 1328+ $j(this).data( 'context' ).$textarea
 1329+ .unbind( 'keypress.srdialog' )
 1330+ .focus();
 1331+ $j(this).closest( '.ui-dialog' ).data( 'dialogaction', false );
13221332 }
13231333 }
13241334 }
Index: trunk/extensions/UsabilityInitiative/EditToolbar/EditToolbar.i18n.php
@@ -115,6 +115,7 @@
116116 'edittoolbar-tool-replace-nomatch' => 'Your search did not match anything.',
117117 'edittoolbar-tool-replace-success' => '$1 replacement(s) made.',
118118 'edittoolbar-tool-replace-emptysearch' => 'You did not enter anything to search for.',
 119+ 'edittoolbar-tool-replace-invalidregex' => 'The regular expression you entered is invalid: $1',
119120 /* Special characters Section */
120121 'edittoolbar-section-characters' => 'Special characters',
121122 'edittoolbar-characters-page-latin' => 'Latin',
@@ -248,6 +249,7 @@
249250 'edittoolbar-tool-replace-close' => '{{Identical|Cancel}}',
250251 'edittoolbar-tool-replace-success' => '[[file:Bulbgraph.png|left|22px]]
251252 This message does not support PLURAL on $1.',
 253+ 'edittoolbar-tool-replace-invalidregex' => '$1 is a browser-supplied error message, probably in English, possibly in the browser language.',
252254 'edittoolbar-characters-page-latin' => 'This is the name of a script, or alphabet, not a language',
253255 'edittoolbar-characters-page-ipa' => 'IPA means a script: "international phonetic alphabet" here, and not "international phonetic association", the organization behind it.',
254256 'edittoolbar-characters-page-greek' => 'This is the name of a script, or alphabet, not a language.',
Index: trunk/extensions/UsabilityInitiative/EditToolbar/EditToolbar.php
@@ -19,7 +19,7 @@
2020 /* Configuration */
2121
2222 // Bump the version number every time you change any of the .css/.js files
23 -$wgEditToolbarStyleVersion = 57;
 23+$wgEditToolbarStyleVersion = 58;
2424
2525 // Set this to true to simply override the stock toolbar for everyone
2626 $wgEditToolbarGlobalEnable = false;

Follow-up revisions

RevisionCommit summaryAuthorDate
r57719wmf-deployment: Merge babaco fixes from trunk...catrope20:20, 14 October 2009

Status & tagging log