Issue: The following errors are returned when Apache Solr Search Integration is used while Securepages is enabled:
* warning: parse_url(/folder/search/apachesolr_search/burton?filters=tid:232) [function.parse-url]: Unable to parse URL in /var/www/html/folder/sites/all/modules/securepages/securepages.module on line 152.
* warning: extract() [function.extract]: First argument should be an array in /var/www/html/folder/sites/all/modules/securepages/securepages.module on line 152.
How to reproduce:
Enable Apache Solr Search Integration & Securepages
Enable facets and facet blocks
Search for a keyword which will return facet blocks
Click on a facet
The result set that is returned will produce the error. This only seems to happen when I apply one facet. Having multiple facets applied to the result set does not produce the error.
Code that throws the error (from Securepages.module):
extract(parse_url($form['#action']));
That is line 52 from a form_alter hook.
I believe the colon before the term_id in the form action is throwing off parse_url().
| Comment | File | Size | Author |
|---|---|---|---|
| #21 | urlencode-401046-21.patch | 1.48 KB | pwolanin |
| #14 | Solr_Base_Query_urlencode_breadcrumb.patch | 762 bytes | mkalkbrenner |
| #11 | Solr_Base_Query.urlencode_filters.patch | 623 bytes | mkalkbrenner |
| #8 | Solr_Base_Query.urlencode_filters.patch | 990 bytes | mkalkbrenner |
| #4 | Solr_Base_Query.urlencode_filters.patch | 569 bytes | mkalkbrenner |
Comments
Comment #1
pwolanin commentedHmm, perhaps we need to urlencode the facet links
Comment #2
mkalkbrennersubscribe
Comment #3
Anonymous (not verified) commentedAgreed, but I couldn't get facets to apply after urlencoding them. Probably missing something small.
EDIT: what I had posted won't work
Comment #4
mkalkbrenner@gregor7777:
I don't have a ssl setup up and running right now. So could you please test this patch for url encoding?
Comment #5
Anonymous (not verified) commentedSure thing, I'll take a look today. thanks
Comment #6
Anonymous (not verified) commentedTested patch, not seeing any difference in behavior.
After applying patch:
http://mysite.com/myfolder/search/apachesolr_search/686?filters=tid:315
...which is a taxonomy facet applied produces:
http://mysite.com/myfolder/search/apachesolr_search/686?filters=tid:315+...
...which is clicking on a second taxonomy facet (keeping the taxonomy facet from the first example applied) produces no warning.
http://mysite.com/myfolder/search/apachesolr_search/686?filters=sm_cck_f...
...which is a CCK field set as a facet produces no warning.
http://mysite.com/myfolder/search/apachesolr_search/686?filters=sm_cck_f...
..which is the same CCK field from above and a taxonomy facet applied produces no warning.
So, to round that up, the only time an warning is produced is the when I apply a taxonomy facet first. Applying a second taxomomy facet, or any combination of applying a CCK field facet does not produce the warning.
This behavior is the same regardless of whether or not the patch was applied.
Comment #7
Anonymous (not verified) commentedforgot to set the status
Comment #8
mkalkbrenner@gregor7777
I made a mistake when using array_walk to encode the filters.
I attached a corrected version of my patch which works for me. Please test again.
Comment #9
Anonymous (not verified) commentedVery nice.
Tested and can confirm that the patch eliminates the warnings, is replacing the offending character in the URL, and appears to have no negative side effects.
Ugly URLs though. :)
http://mysite.com/myfolder/search/apachesolr_search/ski?filters=sort_pri...
Comment #10
pwolanin commentedWhy do we need the urldecode? It seems like will decode when adding to $_GET?
Comment #11
mkalkbrenner@pwolanin:
You're right. I adjusted the patch and removed the additional urldecode.
While playing around with securepages module (which really has some open issues from my point of view) I created a setup where the query string got urlencoded twice.
Comment #12
JacobSingh commentedI didn't test this with securepages because I don't have SSL setup, and don't feel like dealing with it, but it seems to have no effect on normal operation.
Committed.
Comment #14
mkalkbrennerSame strategy for building querystrings as introduced with patch from comment #11 must be applied to breadcrumbs, too.
Because patch from comment #11 is already released, here's an additional one for breadcrumbs.
Comment #15
pwolanin commentedLooks reasonable
Comment #16
pwolanin commentedthe committed patch uses drupal_urlencode() while this patch uses rawurlencode()
So, one (or both) of those must be wrong.
In fact, since this is for the query string (not path) that suggests we shoudl possibly be using:
str_replace('%2F', '/', rawurlencode($text))per the non-clean URL code in http://api.drupal.org/api/function/drupal_urlencode/6
Comment #17
pwolanin commentedper #310139: drupal_query_string_encode() should not call drupal_urlencode() and Damien, we shoudl just use rawurlencode(), which means the previously changed code needs to be similarly altered.
In fact, maybe we shoudl just do this?
Comment #18
pwolanin commentedWiat, now I'm at a loss as to why this is required. We are always passing our query string through url() which means that drupal_query_string_encode() is applied to all of them. What am I missing - it would seem like these changes give us double-encoding.
Comment #19
mkalkbrennerThe patch from #11 used drupal_urlencode and was committed to CVS. Later drupal_urlencode seems to be replaced by rawurlencode in CVS. That's why the patch from #14 now uses rawurlencode, too.
@ #17 pwolanin:
replacing
implode(' ', $fq)byimplode('+', $fq)was one thing needed to solve the incompatibility to secure_pages module.@ #18 pwolanin:
in our cases
$options['query']always seems to be an already prepared querystring and not an array, sodrupal_query_string_encode()will not be called fromurl():So far I can't see any double quoting here in my setup with patch #14 applied.
Comment #20
mkalkbrennerComment #21
pwolanin commentedAh, right - I see why it doesn't get encoded.
Try this patch, since ideally we would not use +
Comment #22
mkalkbrennerI remember that secure_pages chunks an url and than uses
html_build_query()to reconstruct it internally.Output:
Comment #23
pwolanin commentedcan you check if the above patch works?
Comment #24
JacobSingh commentedI'm having trouble testing this because when I enable SSL on my MAMP install. It:
1). Goes slow as hell
2). Fails to make outgoing HTTP requests.
I don't feel like dealing with finding out why, but the patch above doesn't seem to cause any problems when not using secure pages.
Comment #25
pwolanin commentedcommitted to 6.x CVS, follow up if it causes issues.
Comment #26
mkalkbrennerSorry that I reopen this issue.
After reading through some specifications at w3c I'm of the opinion that spaces are not allowed in URLs and must be escaped.
"Spaces and control characters in URLs must be escaped for transmission in HTTP, as must other disallowed characters."
http://www.w3.org/Addressing/URL/url-spec.txt
According to the newer document http://labs.apache.org/webarch/uri/rfc/rfc3986.html in seciton "C. Delimiting a URI in Context" whitespaces delimit an url or must be ignored if they occur within "" or <>. Both treatments of whitespaces will break apachesolr urls.
From my point of view spaces must be escaped as '+'. And in addition to this issue about querystrings, spaces should also be avoided in search key words.
Was there a discussion about spaces in apachesolr urls earlier?
Comment #27
pwolanin commentedWith this patch spaces ARE escaped as '%20', which is the standard for URLs, rather than as '+'.
Comment #28
mkalkbrennerIf I look at your code you must be right. So it seems I made a mistake when applying your patch because I still saw spaces in breadcrumb in our test environment. Please excuse ...
As I wrote the first patch I decided to be compatible to urls created by securepages which used html_build_query(). Unfortunately I'm unable to check if %20 works until Monday.
What do you think about spaces between search key words? Shouldn't these be encoded as well?
Comment #29
pwolanin commentedThe spaces between search keywords will by urlencoded by the Drupal url() function, so I think that's not an issue.
Seems most browsers display %20 decoded, so it may not be obvious when a link actually contains it.
Comment #30
pwolanin commentedlet me know if this is not fixed.