WordPress.org

Make WordPress Core

Opened 20 months ago

Closed 20 months ago

Last modified 20 months ago

#44154 closed defect (bug) (invalid)

saving backslash backslash into user_meta does not round-trip

Reported by: ericscheid Owned by:
Milestone: Priority: normal
Severity: critical Version: 4.9.5
Component: General Keywords:
Focuses: Cc:
PR Number:

Description

This code:

$user_id = get_current_user_id();
$input = 'double ' .chr(92) . chr(92) . ' slashes';

update_user_meta($user_id, 'update_meta_bug', $input);
$output = get_user_meta($user_id, 'update_meta_bug', true);

if ( $output != $input ) {
  echo '<b>$output != $input</b>';
}

Produces this output:

$output != $input

Change History (2)

#1 follow-up: @johnbillion
20 months ago

  • Milestone Awaiting Review deleted
  • Resolution set to invalid
  • Status changed from new to closed

Thanks for the report, @ericscheid . The meta functions expect slashed data. Yes this is nasty, but that's the unfortunate position we're in. You can pass the value through wp_slash() before passing it into this function.

This is not very well documented. See #41593.

#2 in reply to: ↑ 1 @ericscheid
20 months ago

Thanks John.

This is not very well documented. See #41593.

An unenviable tech debt.

Note: See TracTickets for help on using tickets.