Make WordPress Core

Opened 13 years ago

Closed 13 years ago

#18883 closed defect (bug) (fixed)

Notice generated by malformed permalink structures

Reported by: viper007bond's profile Viper007Bond Owned by: ryan's profile ryan
Milestone: 3.3 Priority: lowest
Severity: trivial Version: 3.3
Component: Warnings/Notices Keywords: has-patch
Focuses: Cc:

Description

Set your post permalink structure to this:

/%foobar/%year%/%monthnum%/%day%/%postname%/

Note the missing percent sign after foobar.

That generates this error after saving the structure:

( ! ) Notice: Undefined offset: -1 in \wp-includes\rewrite.php on line 1267
Call Stack
#	Time	Memory	Function	Location
1	0.0011	468272	{main}( )	..\options-permalink.php:0
2	1.3076	25846048	WP_Rewrite->flush_rules( )	..\options-permalink.php:124
3	1.3438	25837416	WP_Rewrite->wp_rewrite_rules( )	..\rewrite.php:1861
4	1.3442	25839872	WP_Rewrite->rewrite_rules( )	..\rewrite.php:1572
5	1.3444	25840976	WP_Rewrite->generate_rewrite_rules( )	..\rewrite.php:1500

This is the line in question:

$query = ( isset($queries) && is_array($queries) ) ? $queries[$num_toks - 1] : '';

Attachments (1)

18883.patch (613 bytes) - added by SergeyBiryukov 13 years ago.

Download all attachments as: .zip

Change History (7)

#1 @Viper007Bond
13 years ago

  • Component changed from Permalinks to Warnings/Notices

#2 @SergeyBiryukov
13 years ago

  • Milestone changed from Awaiting Review to 3.3

Should we just hide the notice or display some error message for the user about invalid structure?

#3 @Viper007Bond
13 years ago

Invalid is a matter of opinion. %foobar gets treated as a static string, as if you were to just type foobar into there (as you can rightfully do). That said, Apache at least treats it as a malformed request so my example breaks permalinks.

I say just stop the notice from occurring and leave it be.

#4 @SergeyBiryukov
13 years ago

  • Keywords has-patch added; needs-patch removed

#5 @kurtpayne
13 years ago

  • Cc kpayne@… added

I was able to recreate the original problem. After applying the patch, I threw a series of special characters at the permalink structure input including even / odd numbers of percents, blank strings, all percents, one percent, etc. I could not get a notice. Patch looks good.

#6 @ryan
13 years ago

  • Owner set to ryan
  • Resolution set to fixed
  • Status changed from new to closed

In [19322]:

Avoid notice when handling malformed permalink structure. Props SergeyBiryukov. fixes #18883

Note: See TracTickets for help on using tickets.