Page MenuHomePhabricator

Filter using combo box input type fails when property values contain ampersand '&' characters
Open, LowPublicBUG REPORT


Author: matt.voysey

Using combo box input type for a drilldown filter, covering a semantic property of type String. On the Browse Data page, the list of property values available for this filter displayed in the combo box includes some strings containing ampersand characters (for example "Electronics & Computer Science"). If one of these values is selected as the filter then no results are returned.

If the standard "list of values" input type is used then the filter works properly when values with ampersands are selected.

Maybe this could be a htmlencode/htmldecode problem reading the selected string from the combo box?

Version: unspecified
Severity: normal



Event Timeline

bzimport raised the priority of this task from to Needs Triage.Nov 21 2014, 11:32 PM
bzimport set Reference to bz28790.

I just tried this out (after a long delay), and it seems like it works for me - are you still seeing this problem?

matt.voysey wrote:

Hi Yaron, I tried this on a clean install of MediaWiki 1.17.0 with SemanticBundle 2011-08-24.20110824 (SemanticDrilldown 0.8.3) and the problem still occurred. So I decided to investigate further...

After some debugging I traced the problem to a difference in the SDAppliedFilter instance that gets created when using a combo box to enter filter values versus the standard list of values input type - I was seeing, for example, "Singer & Songwriter" in the first case, and "Singer & Songwriter" in the second.

Traced the cause of this to SD_AppliedFilter.php line 21, where the value of the _search_ parameter gets htmlspecialchars run on it. Removing this call fixed the problem with ampersands.

In SD_AppliedFilter.php line 21 - change:

$af->search_term = htmlspecialchars( str_replace( '_', ' ', $search_term ) );


$af->search_term = str_replace( '_', ' ', $search_term );

I tested for possible side-effects of the above by creating some other values for property values with nasty <, >, " characters - it seems they already don't work very well with the combo box input (particularly for a value like "Artist" or <Artist> - just don't appear at all), but other values such as Builder's Merchant (containing apostrophe) work fine with or without the fix above.

Aklapper triaged this task as Low priority.Feb 4 2022, 8:07 PM
Aklapper changed the subtype of this task from "Task" to "Bug Report".