I have just installed version 4.7.0 Beta2. I have enabled the locale module. I have imported the french translation file.

When in administer > localization > manage strings if I search for "blog" no string are returned. But if I search for " blog" (with a space in front) more than 30 strings are returned (containing of course the word "blog").

I have done many searches with other words and so far "blog" is the only word which I found having that problem.

CommentFileSizeAuthor
#6 db_escape.diff7.98 KBSteven
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Montuelle’s picture

In fact it seems that the problem happens for search words starting with the letter "b". For example "block" or "based".

Montuelle’s picture

It seems that words starting with "f" also have this problem like "follow" or "frequent".

chx’s picture

Status: Active » Closed (won't fix)

this search is exact search. Copypaste the exact string.

Montuelle’s picture

Status: Closed (won't fix) » Active

Sorry, but I not sure that I understand your answer.
Do you mean that you are unable to reproduce the problem?
I put quotes around blog when reporting my problem, but I don't put quotes in the search field.
For example if I enter Blog (with B in upper case) in the search field, the search returns 10 results one of these being:

<p>Drupal's blog module allows registered users to maintain an online weblog (commonly known as a blog), often referred to as an online journal ...
modules/blog.module:55

If I enter blog (with b in upper case) in the search field, the search returns NO strings.
If I enter blog (with a space in front of the b in upper case) in the search field, the search returns more than 30 results all containing what I am looking for: sentences containing the string blog.

With Drupal version 4.6, I have not this stange behaviour: searching for blog returns all the sentences containing blog with a lower case. Searching for Blog returns all the sentences containing Blog with an upper case.

Montuelle’s picture

Really sorry, but reading again my previous post, I realize that I did some mistakes and I re-submit it (now fixed; please ignore my previous post).

Sorry, but I am not sure that I understand your answer.
Do you mean that you are unable to reproduce the problem?
I put quotes around blog when reporting my problem, but I don't put quotes in the search field.
For example if I enter Blog (with B in upper case) in the search field, the search returns 10 results one of these being:

&lt;p&gt;Drupal&#039;s blog module allows registered users to maintain an online weblog (commonly known as a blog), often referred to as an online journal ...<br />
modules/blog.module:55

If I enter blog (with b in lower case) in the search field, the search returns NO strings.
If I enter &nbsp;blog (with a space in front of the b in lower case) in the search field, the search returns more than 30 results all containing what I am looking for: sentences containing the string blog.

With Drupal version 4.6, I have not this strange behaviour: searching for blog returns all the sentences containing blog with a lower case. Searching for Blog returns all the sentences containing Blog with an upper case.

Steven’s picture

Status: Active » Needs review
FileSize
7.98 KB

locale_string_query() had "%" in its query, instead of "%%". It also used db_escape_string(), which obfuscated the problem and caused the first letter of the string to be interpreted as an sprintf modifier (%s, %d, %f, ...).

Attached a patch which fixes the bug and removes more unnecessary db_escape_string() usage across core.

Steven’s picture

Status: Needs review » Fixed

Tested again to confirm it doesn't break the cleaned up areas, and fixes the locale search bug.

Committed to HEAD due to overwhelming response.

Montuelle’s picture

I have installed the new files from CVS (I am new to this and I don't know yet how to apply a patch). I confirm that the problem which I reported is no longer there.
Thank you very much Steven for this fix.

Dries’s picture

Status: Fixed » Closed (fixed)