Index: trunk/extensions/LiquidThreads/classes/LqtView.php |
— | — | @@ -259,17 +259,27 @@ |
260 | 260 | can temporarily use a random scratch title. It's fine if the title changes |
261 | 261 | throughout the edit cycle, since the article doesn't exist yet anyways. |
262 | 262 | */ |
| 263 | + |
| 264 | + $valid_summary = true; |
| 265 | + |
263 | 266 | if ( $edit_type == 'summarize' && $edit_applies_to->summary() ) { |
264 | 267 | $article = $edit_applies_to->summary(); |
265 | | - } else if ( $edit_type == 'summarize' ) { |
| 268 | + } elseif ( $edit_type == 'summarize' ) { |
266 | 269 | $t = $this->newSummaryTitle( $edit_applies_to ); |
267 | 270 | $article = new Article( $t ); |
268 | | - } else if ( $thread == null ) { |
| 271 | + } elseif ( $thread == null ) { |
269 | 272 | $subject = $this->request->getVal( 'lqt_subject_field', '' ); |
270 | | - if ( $edit_type == 'new' ) { |
271 | | - $t = $this->newScratchTitle( $subject ); |
272 | | - } else if ( $edit_type == 'reply' ) { |
273 | | - $t = $this->newReplyTitle( $subject, $edit_applies_to ); |
| 273 | + |
| 274 | + if ( is_null( Title::makeTitleSafe( NS_LQT_THREAD, $subject ) ) ) { |
| 275 | + // Dodgy title |
| 276 | + $valid_summary = false; |
| 277 | + $t = $this->scratchTitle(); |
| 278 | + } else { |
| 279 | + if ( $edit_type == 'new' ) { |
| 280 | + $t = $this->newScratchTitle( $subject ); |
| 281 | + } elseif ( $edit_type == 'reply' ) { |
| 282 | + $t = $this->newReplyTitle( $subject, $edit_applies_to ); |
| 283 | + } |
274 | 284 | } |
275 | 285 | $article = new Article( $t ); |
276 | 286 | } else { |
— | — | @@ -277,6 +287,18 @@ |
278 | 288 | } |
279 | 289 | |
280 | 290 | $e = new EditPage( $article ); |
| 291 | + |
| 292 | + if (!$valid_summary && $subject) { |
| 293 | + $e->editFormPageTop .= |
| 294 | + Xml::tags( 'div', array( 'class' => 'error' ), |
| 295 | + wfMsgExt( 'lqt_invalid_subject', 'parse' ) ); |
| 296 | + } |
| 297 | + |
| 298 | + if (!$valid_summary) { |
| 299 | + // Dirty hack to prevent saving from going ahead |
| 300 | + global $wgRequest; |
| 301 | + $wgRequest->setVal( 'wpPreview', true ); |
| 302 | + } |
281 | 303 | |
282 | 304 | $e->suppressIntro = true; |
283 | 305 | $e->editFormTextBeforeContent .= |
Index: trunk/extensions/LiquidThreads/Lqt.i18n.php |
— | — | @@ -25,6 +25,10 @@ |
26 | 26 | 'lqt_contents_title' => 'Contents:', |
27 | 27 | 'lqt_add_header' => 'Add header', |
28 | 28 | 'lqt_new_thread' => 'Start a new discussion', |
| 29 | + 'lqt_invalid_subject' => 'The subject you entered is invalid. It may: |
| 30 | +* Contain invalid characters, such as []{}<>, |
| 31 | +* Be too long, or |
| 32 | +* Conflict with interwiki prefixes or namespace names.', |
29 | 33 | 'lqt_in_response_to' => 'In reply to $1 by $2, above:', |
30 | 34 | 'lqt_edited_notice' => 'Edited', |
31 | 35 | 'lqt_reply' => 'Reply', |