Difference between revisions of "Issue:Problem with category containing a single quote character"

From FollowTheScore
Jump to: navigation, search
(New page: {{Issue |Type = Bug |Extension = DPL |Version = 1.7.9 |Description = SQL error when using two categories, one containing a single quote character |Status = open }} ...)
 
m (Problem)
Line 9: Line 9:
 
== Problem ==
 
== Problem ==
 
I use DPL to list all pages that are in two categories, one is "Besoin" (Yes, I'm French) and the other one is the page name.
 
I use DPL to list all pages that are in two categories, one is "Besoin" (Yes, I'm French) and the other one is the page name.
 +
 
So I use the option "category=Besoin&{{PAGENAME}}"
 
So I use the option "category=Besoin&{{PAGENAME}}"
 +
 
When the page name contains a single quote character ', I get an SQL error. The SQL query seems to have 3 different categories : Besoin, the page name to the single quote character and an empty name.
 
When the page name contains a single quote character ', I get an SQL error. The SQL query seems to have 3 different categories : Besoin, the page name to the single quote character and an empty name.
 +
 
I looked at DynamicPageList2.php, and found a way to solve my problem.
 
I looked at DynamicPageList2.php, and found a way to solve my problem.
 +
 
In the section of FILTER PARAMETERS, case category, $sArg contains the value of the option category. But in the case of a page name with a single quote, this character is changed into "'". And the character & is interpreted later as a separator between diferent category names, which is not what is expected...
 
In the section of FILTER PARAMETERS, case category, $sArg contains the value of the option category. But in the case of a page name with a single quote, this character is changed into "'". And the character & is interpreted later as a separator between diferent category names, which is not what is expected...
 +
 
I corrected the problem in a pragmatic but not really efficient way : I added the line  
 
I corrected the problem in a pragmatic but not really efficient way : I added the line  
$sArg = str_replace("'","'",$sArg);
+
 
before the line if (strpos($sArg,'&')!==false) {
+
<tt>$sArg = str_replace("&#39;","'",$sArg);</tt>
 +
 
 +
before the line <tt>if (strpos($sArg,'&')!==false) {</tt>
 +
 
 
With this modification (I can't really call it a correction), the dpl query works.
 
With this modification (I can't really call it a correction), the dpl query works.
 
  
 
== Reply ==
 
== Reply ==

Revision as of 16:16, 9 July 2009

Description: SQL error when using two categories, one containing a single quote character
Extension / Version: DPL   /   1.7.9
Type / Status: Bug   /   open

Problem

I use DPL to list all pages that are in two categories, one is "Besoin" (Yes, I'm French) and the other one is the page name.

So I use the option "category=Besoin&Problem with category containing a single quote character"

When the page name contains a single quote character ', I get an SQL error. The SQL query seems to have 3 different categories : Besoin, the page name to the single quote character and an empty name.

I looked at DynamicPageList2.php, and found a way to solve my problem.

In the section of FILTER PARAMETERS, case category, $sArg contains the value of the option category. But in the case of a page name with a single quote, this character is changed into "'". And the character & is interpreted later as a separator between diferent category names, which is not what is expected...

I corrected the problem in a pragmatic but not really efficient way : I added the line

$sArg = str_replace("'","'",$sArg);

before the line if (strpos($sArg,'&')!==false) {

With this modification (I can't really call it a correction), the dpl query works.

Reply