Special:Upload after following a red link
* Correct the escaping of the autosummary URI fragments.
* (bug 23642) Recognize mime types of MS OpenXML documents.
+* (bug 22784) Normalise underscores and spaces in autocomments.
=== API changes in 1.17 ===
* (bug 22738) Allow filtering by action type on query=logevent.
if ( $title ) {
$section = $auto;
- # Generate a valid anchor name from the section title.
- # Hackish, but should generally work - we strip wiki
- # syntax, including the magic [[: that is used to
- # "link rather than show" in case of images and
- # interlanguage links.
+ # Remove links that a user may have manually put in the autosummary
+ # This could be improved by copying as much of Parser::stripSectionName as desired.
$section = str_replace( '[[:', '', $section );
$section = str_replace( '[[', '', $section );
$section = str_replace( ']]', '', $section );
- # Most of Title:: expects fragments to be escaped
- $section = Title::escapeFragmentForURL( $section );
+ $section = Sanitizer::normalizeSectionNameWhitespace( $section ); # bug 22784
if ( $local ) {
$sectionTitle = Title::newFromText( '#' . $section );
} else {
$text );
}
+ /**
+ * Normalizes whitespace in a section name, such as might be returned
+ * by Parser::stripSectionName(), for use in the id's that are used for
+ * section links.
+ *
+ * @param $section String
+ * @return String
+ */
+ static function normalizeSectionNameWhitespace( $section ) {
+ return trim( preg_replace( '/[ _]+/', ' ', $section ) );
+ }
+
/**
* Ensure that any entities and character references are legal
* for XML and XHTML specifically. Any stray bits will be
# For the anchor, strip out HTML-y stuff period
$safeHeadline = preg_replace( '/<.*?'.'>/', '', $safeHeadline );
- $safeHeadline = preg_replace( '/[ _]+/', ' ', $safeHeadline );
- $safeHeadline = trim( $safeHeadline );
+ $safeHeadline = Sanitizer::normalizeSectionNameWhitespace( $safeHeadline );
# Save headline for section edit hint before it's escaped
$headlineHint = $safeHeadline;
public function guessSectionNameFromWikiText( $text ) {
# Strip out wikitext links(they break the anchor)
$text = $this->stripSectionName( $text );
- $text = trim( preg_replace( '/[ _]+/', ' ', $text ) );
+ $text = Sanitizer::normalizeSectionNameWhitespace( $text );
return '#' . Sanitizer::escapeId( $text, 'noninitial' );
}
<a href="/wiki/Main_Page#section" title="Main Page">#section</a>
!! end
+!! test
+Space normalisation on autocomment (bug 22784)
+!! options
+comment
+title=[[Main Page]]
+!!input
+/* __hello__world__ */
+!! result
+<span class="autocomment"><a href="/wiki/Main_Page#hello_world" title="Main Page">→</a>__hello__world__</span>
+!! end
+
!!article
MediaWiki:bad image list
!!text