While working on a client's site I noticed links with a ? are being converted to &. For example if we post youtube link:
http://www.youtube.com/watch?v=FyiBOcaUq6g once rendered it will look like http://www.youtube.com/watch&v=FyiBOcaUq6g.
After a lot of debugging I located the issue on lines 430-435 in link.module.
// Separate out the query string if any.
if (strpos($url, '?') !== FALSE) {
$query = substr($url, strpos($url, '?') + 1);
parse_str($query, $query_array);
$item['query'] = $query_array;
$url = substr($url, 0, strpos($url, '?'));
}
Removing this lines of code resolved my issue.
Comment | File | Size | Author |
---|---|---|---|
#1 | link.module-fixing_question_mark_converted_to_ampersand-1984398.patch | 768 bytes | chaunceyt |
Comments
Comment #1
chaunceyt CreditAttribution: chaunceyt commentedPatch attached.
Comment #2
rreiss CreditAttribution: rreiss commented@chaunceyt Your patch fixed another issue for me. (Duplicate query params.)
See https://www.drupal.org/node/1646360 for similar issue.
Thanks!
Comment #3
jcfiala CreditAttribution: jcfiala commentedRemember folks - if you post a patch to fix a problem, set the status of the issue to "Needs Review".
If you've tested a patch and agree that it fixes the problem, then set the status of the issue to "Reviewed & Tested by the Community."
Comment #5
jcfiala CreditAttribution: jcfiala commentedHey @chaunceyt, can you give me more information about how this field is setup and being displayed? I've got an automated test that checks that a link with a querystring shows up normally.
If you could give me more information about the specifics of this field - how it's configured - and how it's displayed, that would help.
(I notice this ticket is two years old, so I realize you may not reply.)
Comment #6
jeffwpetersen CreditAttribution: jeffwpetersen commentedI have a similar issue with proxy sites.
http://proxy.kclibrary.org/login?url=http://infotrac.galegroup.com/itweb...
is displayed as
http://proxy.kclibrary.org/login?url=http%3A//infotrac.galegroup.com/itw...
Comment #7
jcfiala CreditAttribution: jcfiala commented@jeffwpeterson - So, the url in question has two ? in it? Well, then it should be doing this - per the internet standard, any ? in a url that isn't indicating that there's a querystring should be encoded. Does the url with the encoded second ? work properly?
(Of course, a lot of websites don't pay attention to the standards.)
Comment #8
jeffwpetersen CreditAttribution: jeffwpetersen commented(entered url) http://proxy.kclibrary.org/login?url=http://infotrac.galegroup.com/itweb...
(result url) http://proxy.kclibrary.org/login?url=http%3A//infotrac.galegroup.com/itw...
http://beta.kclibrary.org/research-resources/research-databases/chiltonl...
In the result url the second ":" is converted to "%3A" after the "?" of the query string. There are not 2 "?";
The entered url works properly from inside the library. The result url throws an error.
This is a proxy filter that allows only url's initiated from inside our system to access that database. It is a standard in libraries as far as I know.
J.
Comment #9
buhuhus CreditAttribution: buhuhus commentedI have the same problem with ":" converted to "%3A" (https://www.drupal.org/node/1984398#comment-9352247) . My Link module version is 7.x-1.3.
Url : http://bookshop.europa.eu/uri?target=EUB:NOTICE:KE6805058:EN:HTML
Displayed URL : http://bookshop.europa.eu/uri?target=EUB%3ANOTICE%3AKE6805058%3AEN%3AHTML
Comment #10
electroponix CreditAttribution: electroponix commentedI also have this issue. Proxy for a library. I have to http://'s in the URL. The second one gets encoded and won't pass through the proxy. Has anyone come up with a fix for this?
Comment #11
KoshaK CreditAttribution: KoshaK commentedI have the problem where ( ) converted to %28 %29 im using 7.x-1.3
Update: ( ) converted only when the " ? " used. by removing " ? " for test purposes the ( ) are in place.
for example the link: http://www.website.com/click?p(123)a(123456)g(123456789)
converts to: http://www.website.com/click?p%28123%29a%28123456%29g%28123456789%29
Comment #12
Summit CreditAttribution: Summit commentedHi,
Tradedoubler urls are also not validated, see also https://www.drupal.org/node/2407553
Is with this patch this validated?
Greetings, Martijn
Comment #13
jeffwpetersen CreditAttribution: jeffwpetersen commentedI have tracked down the bug and think I can explain it more clearly now.
I have a url with a nested query string. The query string is a url itself.
"http://proxy.kclibrary.org/login?url=http://search.proquest.com/abicompl..."
The drupal url() function in the code below (line 518) is altering $url_parts['query'] incorrectly.
http://api.drupal.org/api/drupal/includes%21common.inc/function/url/7
'query': An array of query key/value-pairs (without any URL-encoding) to append to the URL.
This is not an issue in Drupal8. YAY!
Comment #14
jeffwpetersen CreditAttribution: jeffwpetersen commentedComment #15
dgtlmoon CreditAttribution: dgtlmoon commentedComment #16
dgtlmoon CreditAttribution: dgtlmoon commentedSee #1914072: Link Module displays malformed external URL
Comment #17
jeffwpetersen CreditAttribution: jeffwpetersen commentedThe patch does not address this issue.
The query string is being separated out and feed into the url(); function. The url(); function is the problem. See my comment #13 for details.
Comment #18
k.cook CreditAttribution: k.cook commentedAlso having trouble with proxy links. I see that the links on this page are working properly. Is there another fix available that has corrected the trouble with replacing question mark in the queried link?
https://www.kclibrary.org/topics/newspapers
http://proxy.kclibrary.org/login?url=http://search.proquest.com/chicagot...
http://proxy.kclibrary.org/login?url=http://www.bizjournals.com/kansasci...
http://proxy.kclibrary.org/login?url=http://search.proquest.com/newsstan...
Comment #19
k.cook CreditAttribution: k.cook commentedHi. I am trying to solve same issue for using EZProxy URLs. I see that the URLs being used at www.kclibrary.org are now working despite this issue. Jeff - Can you share how this was corrected?
Comment #20
lperepol CreditAttribution: lperepol commentedThis is also an issue with Drupal 8.5.5 and Link Module
URL --
http://ezproxy.library.selkirk.ca/login?url=http://selkirk.kanopy.com/
is converted to:
http://ezproxy.library.selkirk.ca/login?url=http%3A//selkirk.kanopy.com/
Comment #21
lperepol CreditAttribution: lperepol commentedFor EZproxy this may help. "EZProxy: Use qurl, not url, really"
https://bibwild.wordpress.com/2013/01/08/ezproxy-use-qurl-not-url-really/
Comment #22
ismailM CreditAttribution: ismailM commentedI'm having the same issue with Drupal 8.5.5^
Is there a solution to fix this? Thanks!
Comment #23
jeffwpetersen CreditAttribution: jeffwpetersen commentedComment out part of this function to make proxy work.