Trim spaces on user supplied comments
authorumherirrender <umherirrender_de.wp@web.de>
Sat, 1 Dec 2012 19:11:21 +0000 (20:11 +0100)
committerGerrit Code Review <gerrit@wikimedia.org>
Sun, 20 Jan 2013 14:08:38 +0000 (14:08 +0000)
This helps on bug 29575

Change-Id: Ic05e5898f8a7c93a95188c9342d22c70d7413b09

includes/EditPage.php
includes/RecentChange.php
includes/WikiPage.php
includes/filerepo/file/LocalFile.php
includes/logging/LogEntry.php
includes/logging/LogPage.php

index f3c0237..5f38cf3 100644 (file)
@@ -617,8 +617,11 @@ class EditPage {
                                wfProfileOut( get_class( $this ) . "::importContentFormData" );
                        }
 
+                       # Trim spaces on user supplied text
+                       $summary = trim( $request->getText( 'wpSummary' ) );
+
                        # Truncate for whole multibyte characters
-                       $this->summary = $wgContLang->truncate( $request->getText( 'wpSummary' ), 255 );
+                       $this->summary = $wgContLang->truncate( $summary, 255 );
 
                        # If the summary consists of a heading, e.g. '==Foobar==', extract the title from the
                        # header syntax, e.g. 'Foobar'. This is mainly an issue when we are using wpSummary for
index 87fa428..56df21e 100644 (file)
@@ -235,6 +235,9 @@ class RecentChange {
                        unset( $this->mAttribs['rc_ip'] );
                }
 
+               # Trim spaces on user supplied text
+               $this->mAttribs['rc_comment'] = trim( $this->mAttribs['rc_comment'] );
+
                # Make sure summary is truncated (whole multibyte characters)
                $this->mAttribs['rc_comment'] = $wgContLang->truncate( $this->mAttribs['rc_comment'], 255 );
 
index 70ed7e7..e2cd5d9 100644 (file)
@@ -2792,6 +2792,9 @@ class WikiPage extends Page implements IDBAccessObject {
                        $summary = wfMsgReplaceArgs( $summary, $args );
                }
 
+               // Trim spaces on user supplied text
+               $summary = trim( $summary );
+
                // Truncate for whole multibyte characters.
                $summary = $wgContLang->truncate( $summary, 255 );
 
index a9678b7..9babe5a 100644 (file)
@@ -996,6 +996,9 @@ class LocalFile extends File {
                        $options['headers'] = array();
                }
 
+               // Trim spaces on user supplied text
+               $comment = trim( $comment );
+
                // truncate nicely or the DB will do it for us
                // non-nicely (dangling multi-byte chars, non-truncated version in cache).
                $comment = $wgContLang->truncate( $comment, 255 );
index 1f94b43..ed9aa5a 100644 (file)
@@ -442,8 +442,11 @@ class ManualLogEntry extends LogEntryBase {
                        $this->timestamp = wfTimestampNow();
                }
 
+               # Trim spaces on user supplied text
+               $comment = trim( $this->getComment() );
+
                # Truncate for whole multibyte characters.
-               $comment = $wgContLang->truncate( $this->getComment(), 255 );
+               $comment = $wgContLang->truncate( $comment, 255 );
 
                $data = array(
                        'log_id' => $id,
index 07238a0..5854e99 100644 (file)
@@ -421,6 +421,9 @@ class LogPage {
                        $comment = '';
                }
 
+               # Trim spaces on user supplied text
+               $comment = trim( $comment );
+
                # Truncate for whole multibyte characters.
                $comment = $wgContLang->truncate( $comment, 255 );