Index: trunk/phase3/tests/qunit/suites/resources/mediawiki/mediawiki.util.test.js |
— | — | @@ -107,7 +107,7 @@ |
108 | 108 | }); |
109 | 109 | |
110 | 110 | test( 'getParamValue', function() { |
111 | | - expect(3); |
| 111 | + expect(4); |
112 | 112 | |
113 | 113 | var url1 = 'http://mediawiki.org/?foo=wrong&foo=right#&foo=bad'; |
114 | 114 | |
— | — | @@ -116,6 +116,9 @@ |
117 | 117 | |
118 | 118 | var url2 = 'http://mediawiki.org/#&foo=bad'; |
119 | 119 | strictEqual( mw.util.getParamValue( 'foo', url2 ), null, 'Ignore hash if param is not in querystring but in hash (bug 27427)' ); |
| 120 | + |
| 121 | + var url3 = 'example.com?' + $.param({ 'TEST': 'a b+c' }); |
| 122 | + strictEqual( mw.util.getParamValue( 'TEST', url3 ), 'a b+c', 'Bug 30441: getParamValue must understand "+" encoding of space' ); |
120 | 123 | }); |
121 | 124 | |
122 | 125 | test( 'tooltipAccessKey', function() { |
Index: trunk/phase3/resources/mediawiki/mediawiki.util.js |
— | — | @@ -226,7 +226,9 @@ |
227 | 227 | var re = new RegExp( '^[^#]*[&?]' + $.escapeRE( param ) + '=([^&#]*)' ); |
228 | 228 | var m = re.exec( url ); |
229 | 229 | if ( m && m.length > 1 ) { |
230 | | - return decodeURIComponent( m[1] ); |
| 230 | + // Beware that decodeURIComponent is not required to understand '+' |
| 231 | + // by spec, as encodeURIComponent does not produce it. |
| 232 | + return decodeURIComponent( m[1].replace( '+', '%20' ) ); |
231 | 233 | } |
232 | 234 | return null; |
233 | 235 | }, |