Make WordPress Core

Opened 21 years ago

Closed 19 years ago

#914 closed defect (bug) (fixed)

wrong search string escaping/slashes

Reported by: nbachiyski's profile nbachiyski Owned by: ryan's profile ryan
Milestone: 2.1 Priority: normal
Severity: minor Version: 2.0.7
Component: Template Keywords: has-patch commit
Focuses: Cc:

Description

Search for ' and
\' will appear in the input field.
" ->
\
& -> &

Attachments (2)

search-slashes.diff (2.2 KB) - added by nbachiyski 21 years ago.
914.diff (1.9 KB) - added by mdawaffe 19 years ago.
give it an template tag

Download all attachments as: .zip

Change History (21)

#1 @nbachiyski
21 years ago

  • Patch set to No

#2 @nbachiyski
21 years ago

In classes.php $qs? is added slashes again, despite the fact that is has passed through add_magic_quotes function before.

For database use the search string needs slashes, but when writing it to the templates is does not. I have added striptags calls in the template pages.

#3 @ryan
21 years ago

  • Patch changed from No to Yes

#4 @ryan
21 years ago

  • Owner changed from anonymous to rboren
  • Status changed from new to assigned

#5 @ryan
21 years ago

Even if we get rid of the extra addslashes, searches will still show a single set of slashes. \' instead of
\'. We can either add stripslashes to Kubrick's templates, or not addslashes by default when processing GPC in the blog header. Not adding slashes by default and instead relying on those functions that query the DB to addslashes as appropriate seems to be the cleanest way to do this, but that should wait until after 1.5.1.

#6 @nbachiyski
21 years ago

I also prefer not adding slashes by default and escape strings only for DB operations.

Now, as I understand, the choice is between leaving the bug in 1.5.1 or applying the dirty "stripslashes in Kubrick" hack before reorganizing all that code. My choice was the second.

Which is the less evil of the two?

#7 @dwc
21 years ago

  • Cc daniel@… added

@mdawaffe
19 years ago

give it an template tag

#8 @mdawaffe
19 years ago

  • Keywords has-patch commit added
  • Milestone set to 2.1

914.diff

  1. create wp_search_query() template tag which echos the query.

#9 @ryan
19 years ago

Whatcha think, wp_search_query() or the_search_query()? Or maybe just the_search()? These are important questions. :-)

#10 @markjaquith
19 years ago

the_search_query() or search_query()

the wp_blah() ones usually accept a query string with a bunch of parameters.

#11 @mdawaffe
19 years ago

I like the_search_query(), but search_query() is a much better band name.

#12 @ryan
19 years ago

  • Resolution set to fixed
  • Status changed from assigned to closed

(In [4171]) the_search_query() from mdawaffe. fixes #914

#13 @thenlich
19 years ago

  • Resolution fixed deleted
  • Status changed from closed to reopened
  • Version changed from 1.5 to 2.0.7

Found the same problem in 2.0.7
' (single quote) becomes


\' with magic_quotes_gpc on (7 backslashes, then single quote),
or
\' (magic_quotes_gpc=off) (3 backslashes, quote)

#14 @ryan
19 years ago

With one of the default themes? If you're having problems with a third party theme, that theme needs to be changed.

#15 @thenlich
19 years ago

Yes, with theme: WordPress Default 1.6

#16 @foolswisdom
19 years ago

  • Milestone changed from 2.1 to 2.1.1

#17 @markjaquith
19 years ago

  • Resolution set to worksforme
  • Status changed from reopened to closed

thenlich, please upgrade to the most recent version of the theme (the one in 2.0.7). Re-open with a URL demonstrating the issue, if it persists.

#18 @foolswisdom
19 years ago

  • Milestone changed from 2.1.1 to 2.1
  • Resolution worksforme deleted
  • Status changed from closed to reopened

Changing back to previous fixed state.

#19 @foolswisdom
19 years ago

  • Resolution set to fixed
  • Status changed from reopened to closed
Note: See TracTickets for help on using tickets.