Make WordPress Core

Opened 20 years ago

Closed 20 years ago

#2853 closed defect (bug) (fixed)

404 error while saving options

Reported by: ishbir's profile Ishbir Owned by:
Milestone: 2.1 Priority: normal
Severity: normal Version: 2.0.4
Component: Administration Keywords: 404 options bg|has-patch
Focuses: Cc:

Description

There is bug in options.php (not options-general.php) which redirects to http://www.example.com/wp-admin/updated=true. That should redirect to http://www.example.com/wp-admin/options-general.php. I have already made its fix. You may have it at http://www.ishbir.com/wpfix1.zip. The fix was in the line

$goback = add_query_arg('updated', 'true', $_SERVER['HTTP_REFERER']); 

Whereas, it had to be

$goback = add_query_arg('options-general.php?updated', 'true', $_SERVER['HTTP_REFERER']);

I have already fixed it to make it easier for you to search thousands of lines of code. Please include this fix in your next version of Wordpress.

Regards,
Ishbir Singh

Attachments (1)

2853.diff (551 bytes) - added by Nazgul 20 years ago.
Diff based on wpfix1.zip by reporter

Download all attachments as: .zip

Change History (10)

#1 @tereshchenko
20 years ago

A variation of this bug happened for me with all "Options" pages (I used version from "2.0" branch - yesterday, 23:00GMT). Instead of normal address I was redirected to the address without "http://" part (which is obviously treated by server as non-existing filename).

@Nazgul
20 years ago

Diff based on wpfix1.zip by reporter

#2 @Nazgul
20 years ago

  • Keywords 404 options bg|has-patch added
  • Milestone set to 2.1
  • Priority changed from highest to normal
  • Severity changed from critical to normal

I've been unable to reproduce this on both my own blogs (2.0.3 and SVN), but other people on the support forums have reported this issue as well.

See also http://wordpress.org/support/topic/75064 and http://wordpress.org/support/topic/34165

#3 @ryan
20 years ago

That fix will probably break the goback for the other options pages that use options.php. Referrers need to be enabled for all of the redirects to work.

#4 @tereshchenko
20 years ago

I compared files in 2.0.2 (which worked fine) and current SVN - and found that add_query_arg() function was modified for 2.0.3

Following code was added:

	if ( preg_match('|^https?://|i', $uri, $matches) ) {
		$protocol = $matches[0];
		$uri = substr($uri, strlen($protocol));
	} else {
		$protocol = '';
	}

I suspect the issue's in it.

#5 @tereshchenko
20 years ago

Correction - it was modified after 2.0.3 (which worked fine for me BTW).

#6 @tereshchenko
20 years ago

So protocol is removed from the URI:

$uri = substr($uri, strlen($protocol));

and kept in variable $protocol - which is never used again (which I think means that new URL will be without http:// part).

#7 @ryan
20 years ago

Good catch. That change wasn't properly ported from trunk. [3905]

I'm not sure this is the same issue as the orginal reporter's though.

#8 @tereshchenko
20 years ago

Yep, that is fix for my problem only :-)

Then again, thinking of original issue - looks like such situation possible only when $_SERVERHTTP_REFERER? is empty string. In this case the result of the function will be updated=true and this will be treated as a file in /wp-admin/ directory.
So to fix this either users should trash their incompetent firewalls, or whitelist their own website, or WordPress shouldn't rely on referer in such redirects.

#9 @ryan
20 years ago

  • Resolution set to fixed
  • Status changed from new to closed
  • Version set to 2.0.4

The problem encountered when referrers are disabled is fixed by a new method of passing referrers. See bug #2800 for details. The commits for that bug fix the options 404 issue for both trunk and the 2.0 branch.

Note: See TracTickets for help on using tickets.