Ticket #4781 (closed defect: fixed)

Opened 1 year ago

Last modified 4 months ago

update_option destroys value / faulty trim

Reported by: hakre Assigned to: anonymous
Priority: normal Milestone: 2.6
Component: Administration Version: 2.2.2
Severity: normal Keywords: update_option trim has-patch
Cc: westi

Description

When using wordpress option function "update_option" and the value of the option is a string containing trailing spaces (wether in front or at the end), these spaces will be removed. This can destroy the option value since spaces are chars like any other chars in a string. The option value then is saved crippeled into the option system and each time the value is requested again trailing spaces are missing.

The defect is inside the update_option() function on line 281 in functions.php. In line 289 the option value type is checked to be a string and if it is a string, the string value will be trimmed:

if ( is_string($newvalue) )
		$newvalue = trim($newvalue);

It is totally unclear why this happens, the sourcecode isn't documented in any way. I applied a diff against the current SVN that removes these two lines of faulty code.

Attachments

4781.diff (0.5 kB) - added by hakre on 08/20/07 15:47:32.

Change History

08/20/07 15:47:32 changed by hakre

  • attachment 4781.diff added.

08/20/07 15:47:58 changed by hakre

  • keywords changed from update_option trim to update_option trim has-patch.

08/21/07 20:29:30 changed by markjaquith

  • milestone changed from 2.2.3 to 2.4 (future).

This is likely legacy code. I have no problem axing it.

12/09/07 11:49:25 changed by westi

  • status changed from new to closed.
  • resolution set to fixed.

(In [6367]) Remove triming from string options fixes #4781 props hakre

06/13/08 05:48:49 changed by hakre

  • cc set to westi.
  • status changed from closed to reopened.
  • resolution deleted.

There is a regression on this bug. The usage of maybe_serialize() which was not in there the time this was fixed, leads to a trim _again_.

See #7132

06/16/08 20:39:38 changed by ryan

  • milestone changed from 2.5 to 2.5.2.

06/16/08 20:41:02 changed by ryan

  • status changed from reopened to closed.
  • resolution set to fixed.

(In [8100]) Don't trim strings in maybe_serialize(). Props hakre. fixes #7132 #7133 #4781 for trunk

06/16/08 20:41:15 changed by ryan

(In [8101]) Don't trim strings in maybe_serialize(). Props hakre. fixes #7132 #7133 #4781 for 2.5

07/15/08 16:24:07 changed by ryan

  • milestone changed from 2.5.2 to 2.9.

Milestone 2.5.2 deleted

07/30/08 20:27:43 changed by westi

  • milestone changed from 2.9 to 2.6.