Index: trunk/phase3/includes/Linker.php |
— | — | @@ -1184,46 +1184,58 @@ |
1185 | 1185 | * @todo Document the $local parameter. |
1186 | 1186 | */ |
1187 | 1187 | private function formatAutocomments( $comment, $title = null, $local = false ) { |
1188 | | - $match = array(); |
1189 | | - while (preg_match('!(.*)/\*\s*(.*?)\s*\*/(.*)!', $comment,$match)) { |
1190 | | - $pre=$match[1]; |
1191 | | - $auto=$match[2]; |
1192 | | - $post=$match[3]; |
1193 | | - $link=''; |
1194 | | - if( $title ) { |
1195 | | - $section = $auto; |
| 1188 | + // Bah! |
| 1189 | + $this->autocommentTitle = $title; |
| 1190 | + $this->autocommentLocal = $local; |
| 1191 | + $comment = preg_replace_callback( |
| 1192 | + '!(.*?)/\*\s*(.*?)\s*\*/(.*?)!', |
| 1193 | + array( $this, 'formatAutocommentsCallback' ), |
| 1194 | + $comment ); |
| 1195 | + unset( $this->autocommentTitle ); |
| 1196 | + unset( $this->autocommentLocal ); |
| 1197 | + return $comment; |
| 1198 | + } |
| 1199 | + |
| 1200 | + private function formatAutocommentsCallback( $match ) { |
| 1201 | + $title = $this->autocommentTitle; |
| 1202 | + $local = $this->autocommentLocal; |
| 1203 | + |
| 1204 | + $pre=$match[1]; |
| 1205 | + $auto=$match[2]; |
| 1206 | + $post=$match[3]; |
| 1207 | + $link=''; |
| 1208 | + if( $title ) { |
| 1209 | + $section = $auto; |
1196 | 1210 | |
1197 | | - # Generate a valid anchor name from the section title. |
1198 | | - # Hackish, but should generally work - we strip wiki |
1199 | | - # syntax, including the magic [[: that is used to |
1200 | | - # "link rather than show" in case of images and |
1201 | | - # interlanguage links. |
1202 | | - $section = str_replace( '[[:', '', $section ); |
1203 | | - $section = str_replace( '[[', '', $section ); |
1204 | | - $section = str_replace( ']]', '', $section ); |
1205 | | - if ( $local ) { |
1206 | | - $sectionTitle = Title::newFromText( '#' . $section ); |
1207 | | - } else { |
1208 | | - $sectionTitle = clone( $title ); |
1209 | | - $sectionTitle->mFragment = $section; |
1210 | | - } |
1211 | | - $link = $this->link( $sectionTitle, |
1212 | | - wfMsgForContent( 'sectionlink' ), array(), array(), |
1213 | | - 'noclasses' ); |
| 1211 | + # Generate a valid anchor name from the section title. |
| 1212 | + # Hackish, but should generally work - we strip wiki |
| 1213 | + # syntax, including the magic [[: that is used to |
| 1214 | + # "link rather than show" in case of images and |
| 1215 | + # interlanguage links. |
| 1216 | + $section = str_replace( '[[:', '', $section ); |
| 1217 | + $section = str_replace( '[[', '', $section ); |
| 1218 | + $section = str_replace( ']]', '', $section ); |
| 1219 | + if ( $local ) { |
| 1220 | + $sectionTitle = Title::newFromText( '#' . $section ); |
| 1221 | + } else { |
| 1222 | + $sectionTitle = clone( $title ); |
| 1223 | + $sectionTitle->mFragment = $section; |
1214 | 1224 | } |
1215 | | - $auto = $link . $auto; |
1216 | | - if( $pre ) { |
1217 | | - # written summary $presep autocomment (summary /* section */) |
1218 | | - $auto = wfMsgExt( 'autocomment-prefix', array( 'escapenoentities', 'content' ) ) . $auto; |
1219 | | - } |
1220 | | - if( $post ) { |
1221 | | - # autocomment $postsep written summary (/* section */ summary) |
1222 | | - $auto .= wfMsgExt( 'colon-separator', array( 'escapenoentities', 'content' ) ); |
1223 | | - } |
1224 | | - $auto = '<span class="autocomment">' . $auto . '</span>'; |
1225 | | - $comment = $pre . $auto . $post; |
| 1225 | + $link = $this->link( $sectionTitle, |
| 1226 | + wfMsgForContent( 'sectionlink' ), array(), array(), |
| 1227 | + 'noclasses' ); |
1226 | 1228 | } |
1227 | | - |
| 1229 | + $auto = $link . $auto; |
| 1230 | + if( $pre ) { |
| 1231 | + # written summary $presep autocomment (summary /* section */) |
| 1232 | + $auto = wfMsgExt( 'autocomment-prefix', array( 'escapenoentities', 'content' ) ) . $auto; |
| 1233 | + } |
| 1234 | + if( $post ) { |
| 1235 | + # autocomment $postsep written summary (/* section */ summary) |
| 1236 | + $auto .= wfMsgExt( 'colon-separator', array( 'escapenoentities', 'content' ) ); |
| 1237 | + } |
| 1238 | + $auto = '<span class="autocomment">' . $auto . '</span>'; |
| 1239 | + $comment = $pre . $auto . $post; |
1228 | 1240 | return $comment; |
1229 | 1241 | } |
1230 | 1242 | |
Index: trunk/phase3/RELEASE-NOTES |
— | — | @@ -126,6 +126,8 @@ |
127 | 127 | * (bug 13770) Fixed incorrect detection of PHP's DOM module |
128 | 128 | * (bug 14790) Export of category pages when using Category: prefix now actually |
129 | 129 | gives results |
| 130 | +* Avoid recursive crazy expansions in section edit comments for pages which |
| 131 | + contain '/*' in the title |
130 | 132 | |
131 | 133 | === API changes in 1.14 === |
132 | 134 | |