Index: trunk/phase3/includes/Html.php |
— | — | @@ -353,17 +353,23 @@ |
354 | 354 | # and we don't need <> escaped here, we may as well not call |
355 | 355 | # htmlspecialchars(). FIXME: verify that we actually need to |
356 | 356 | # escape \n\r\t here, and explain why, exactly. |
357 | | - if ( $wgHtml5 ) { |
358 | | - $ret .= " $key=$quote" . strtr( $value, array( |
359 | | - '&' => '&', |
360 | | - '"' => '"', |
361 | | - "\n" => ' ', |
362 | | - "\r" => ' ', |
363 | | - "\t" => '	' |
364 | | - ) ) . $quote; |
365 | | - } else { |
366 | | - $ret .= " $key=$quote" . Sanitizer::encodeAttribute( $value ) . $quote; |
| 357 | + # |
| 358 | + # We could call Sanitizer::encodeAttribute() for this, but we |
| 359 | + # don't because we're stubborn and like our marginal savings on |
| 360 | + # byte size from not having to encode unnecessary quotes. |
| 361 | + $map = array( |
| 362 | + '&' => '&', |
| 363 | + '"' => '"', |
| 364 | + "\n" => ' ', |
| 365 | + "\r" => ' ', |
| 366 | + "\t" => '	' |
| 367 | + ); |
| 368 | + if ( $wgWellFormedXml ) { |
| 369 | + # '<' must be escaped in attributes for XML for some |
| 370 | + # reason, per spec: http://www.w3.org/TR/xml/#NT-AttValue |
| 371 | + $map['<'] = '<'; |
367 | 372 | } |
| 373 | + $ret .= " $key=$quote" . strtr( $value, $map ) . $quote; |
368 | 374 | } |
369 | 375 | } |
370 | 376 | return $ret; |