Index: trunk/extensions/Translate/utils/MessageWebImporter.php |
— | — | @@ -169,13 +169,8 @@ |
170 | 170 | $type = 'changed'; |
171 | 171 | |
172 | 172 | global $wgRequest; |
| 173 | + $action = $wgRequest->getVal( self::escapeNameForPHP( "action-$type-$key" ) ); |
173 | 174 | |
174 | | - # Spaces don't seem to survive round trip in addition to dots |
175 | | - # which are silently handled in getVal |
176 | | - $safekey = str_replace( ' ', '_', $key ); |
177 | | - $safekey = str_replace( '.', '_', $key ); |
178 | | - $action = $wgRequest->getVal( "action-$type-$safekey" ); |
179 | | - |
180 | 175 | if ( $process ) { |
181 | 176 | if ( !count( $changed ) ) { |
182 | 177 | $changed[] = '<ul>'; |
— | — | @@ -221,7 +216,9 @@ |
222 | 217 | |
223 | 218 | foreach ( $actions as $action ) { |
224 | 219 | $label = wfMsg( "translate-manage-action-$action" ); |
225 | | - $act[] = Xml::radioLabel( $label, "action-$type-$key", $action, "action-$key-$action", $action === $defaction ); |
| 220 | + $name = self::escapeNameForPHP( "action-$type-$key" ); |
| 221 | + $id = Sanitizer::escapeId( "action-$key-$action" ); |
| 222 | + $act[] = Xml::radioLabel( $label, $nameid, $action, $id, $action === $defaction ); |
226 | 223 | } |
227 | 224 | |
228 | 225 | $name = wfMsg( 'translate-manage-import-diff', |
— | — | @@ -434,10 +431,10 @@ |
435 | 432 | /** |
436 | 433 | * Make section elements. |
437 | 434 | * |
438 | | - * @param $legend \string Legend |
439 | | - * @param $type\string Contents of type class |
440 | | - * @param $content \string Contents |
441 | | - * @return \string Section element |
| 435 | + * @param $legend \string Legend as raw html. |
| 436 | + * @param $type \string Contents of type class. |
| 437 | + * @param $content \string Contents as raw html. |
| 438 | + * @return \string Section element as html. |
442 | 439 | */ |
443 | 440 | public static function makeSectionElement( $legend, $type, $content ) { |
444 | 441 | $containerParams = array( 'class' => "mw-tpt-sp-section mw-tpt-sp-section-type-{$type}" ); |
— | — | @@ -462,4 +459,28 @@ |
463 | 460 | |
464 | 461 | return TRANSLATE_FUZZY . $message; |
465 | 462 | } |
| 463 | + |
| 464 | + /** |
| 465 | + * Escape name such that it validates as name and id parameter in html, and |
| 466 | + * so that we can get it back with WebRequest::getVal(). Especially dot and |
| 467 | + * spaces are difficult for the latter. |
| 468 | + * @param $name \string |
| 469 | + * @return \string |
| 470 | + */ |
| 471 | + public static function escapeNameForPHP( $name ) { |
| 472 | + $replacements = array( |
| 473 | + "(" => '(OP)', |
| 474 | + " " => '(SP)', |
| 475 | + "\t" => '(TAB)', |
| 476 | + "." => '(DOT)', |
| 477 | + "'" => '(SQ)', |
| 478 | + "\"" => '(DQ)', |
| 479 | + "%" => '(PC)', |
| 480 | + "&" => '(AMP)', |
| 481 | + ); |
| 482 | + |
| 483 | + /* How nice of you PHP. No way to split array into keys and values in one |
| 484 | + * function or have str_replace which takes one array? */ |
| 485 | + return str_replace( array_keys( $replacements ), array_values( $replacements ), $name ); |
| 486 | + } |
466 | 487 | } |