WordPress.org

Make WordPress Core

Opened 11 years ago

Closed 10 years ago

#6394 closed defect (bug) (duplicate)

Leading and trailing white space in values of custom fields should not be trimmed

Reported by: aercolino Owned by: markjaquith
Milestone: Priority: normal
Severity: normal Version:
Component: Administration Keywords: meta value, custom field
Focuses: Cc:

Description

Custom fields that begin or end with white space in their key or value are trimmed.

I can undestand that a key is more easily dealt with if it is trimmed before saving it into the database. But values should definitely retain all their white space AS IS.

Suggested Fix

http://trac.wordpress.org/browser/trunk/wp-includes/functions.php#L405 (7508)

function maybe_serialize($data, $trim = true) { //was maybe_serialize($data)

http://trac.wordpress.org/browser/trunk/wp-includes/functions.php#L406 (7508)

if ( $trim && is_string($data) ) //was if ( is_string( $data ) )

http://trac.wordpress.org/browser/trunk/wp-admin/includes/post.php#L365 (7458)

$metavalue = maybe_serialize( stripslashes( ( $_POST['metavalue'] ) ), false ); //was $metavalue = maybe_serialize( stripslashes( (trim( $_POST['metavalue'] ) ) ));

http://trac.wordpress.org/browser/trunk/wp-admin/includes/post.php#L449 (7458)

$mvalue = maybe_serialize( stripslashes( $mvalue ), false ); //was $mvalue = maybe_serialize( stripslashes( $mvalue ));

WordPress Rendering Troubles

Change History (3)

#1 @hakre
11 years ago

Do not fix what is broken. I suggest to remove maybe_serialize(). This function is absolutely esoteric and undocumented with a high potential of fuzz.

#2 @Denis-de-Bernardy
10 years ago

  • Component changed from General to Administration

#3 @Denis-de-Bernardy
10 years ago

  • Milestone 2.9 deleted
  • Resolution set to duplicate
  • Status changed from new to closed

this has been fixed in 2.8, in a separate ticket.

Note: See TracTickets for help on using tickets.