Ticket #914 (closed defect (bug): fixed)

Opened 7 years ago

Last modified 5 years ago

wrong search string escaping/slashes

Reported by: nbachiyski Owned by: ryan
Priority: normal Milestone: 2.1
Component: Template Version: 2.0.7
Severity: minor Keywords: has-patch commit
Cc: daniel@…

Description

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

Attachments

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

Change History

  • Patch set to No

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.

comment:3   ryan7 years ago

  • Patch changed from No to Yes

comment:4   ryan7 years ago

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

comment:5   ryan7 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.

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?

comment:7   dwc7 years ago

  • Cc daniel@… added

give it an template tag

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

914.diff

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

comment:9   ryan5 years ago

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

the_search_query() or search_query()

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

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

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

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

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

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)

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

Yes, with theme: WordPress Default 1.6

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

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.

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

Changing back to previous fixed state.

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