r105018 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r105017‎ | r105018 | r105019 >
Date:22:53, 2 December 2011
Author:foxtrott
Status:deferred
Tags:
Comment:
fix bug 25588 (Faulty regexp breaks JS execution)
Modified paths:
  • /trunk/extensions/SemanticFormsInputs/SemanticFormsInputs.i18n.php (modified) (history)
  • /trunk/extensions/SemanticFormsInputs/libs/regexp.js (modified) (history)

Diff [purge]

Index: trunk/extensions/SemanticFormsInputs/SemanticFormsInputs.i18n.php
@@ -15,6 +15,7 @@
1616 'semanticformsinputs-dateformatlong' => 'd MM yy', // see http://docs.jquery.com/UI/Datepicker/formatDate
1717 'semanticformsinputs-dateformatshort' => 'dd/mm/yy', // see http://docs.jquery.com/UI/Datepicker/formatDate
1818 'semanticformsinputs-firstdayofweek' => '0', // 0 - sunday, 1 - monday...
 19+ 'semanticformsinputs-malformedregexp' => 'Malformed regular expression ($1).',
1920
2021 'semanticformsinputs-datepicker-dateformat' => 'The date format string. See the [http://www.mediawiki.org/w/index.php?title=Extension:Semantic_Forms_Inputs&fromsection=Date_picker#Parameters online documentation] for more information.',
2122 'semanticformsinputs-datepicker-weekstart' => 'The first day of the week (0 - Sunday, 1 - Monday, ...).',
@@ -63,6 +64,7 @@
6465
6566 {{doc-important|This is an ''optional'' message. Do not translate it, if it would remain unchanged in your language. }}",
6667 'semanticformsinputs-firstdayofweek' => '0 - sunday, 1 - monday...',
 68+ 'semanticformsinputs-malformedregexp' => 'An error message.',
6769
6870 'semanticformsinputs-datepicker-dateformat' => 'This is a help text for the Special:CreateForm page.',
6971 'semanticformsinputs-datepicker-weekstart' => 'This is a help text for the Special:CreateForm page.',
Index: trunk/extensions/SemanticFormsInputs/libs/regexp.js
@@ -18,13 +18,21 @@
1919 */
2020 function SFI_RE_validate ( input_id, params ) { //input_number, retext, inverse, message, multiple
2121
22 - var re = new RegExp( jQuery( "<div/>" ).html( params.retext ).text() );
23 - var match = re.test( jQuery('#' + input_id).attr("value") );
 22+ var match;
 23+ var message;
 24+ try {
 25+ var re = new RegExp( jQuery( "<div/>" ).html( params.retext ).text() );
 26+ match = re.test( jQuery('#' + input_id).attr("value") );
 27+ message = params.message;
 28+ } catch (e) {
 29+ match = false;
 30+ message = params.error.replace('$1', e );
 31+ }
2432
2533 if ( ( match && ! params.inverse ) || ( ! match && params.inverse ) ) {
2634 return true;
2735 } else {
28 - jQuery( '#' + input_id ).parent().addErrorMessage(params.message);
 36+ jQuery( '#' + input_id ).parent().addErrorMessage( message );
2937 return false;
3038 }
3139 }