Closed (fixed)
Project:
CAPTCHA
Version:
7.x-1.3
Component:
User interface
Priority:
Critical
Category:
Bug report
Assigned:
Issue tags:
Reporter:
Created:
30 Mar 2015 at 19:46 UTC
Updated:
11 Nov 2015 at 01:48 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #1
jc2 commentedSame for me... it was working fine and now this message appears: Resource interpreted as Image but transferred with MIME type text/html: "http://example.org/?q=image_captcha&sid=38&ts=1427818537".
Comment #2
bulit commentedSame for me... what can I do if I can not login as administrator?
Comment #3
shanes@tccompany.com commentedWe are experiencing the same issue with 7.x-1.3.
Upon further examination, we have found that the image source looks like this:
<img typeof="foaf:Image" src="/?q=image_captcha&amp;sid=20&amp;ts=1427834487" width="252" height="60" alt="Image CAPTCHA" title="Image CAPTCHA">The ampersand is being double-escaped.
Copying the source out, and correcting it in the browser, like so:
<site>/?q=image_captcha&sid=20&ts=1427834487Does indeed show us the image.
Comment #4
Wildecard commentedShanes right on the money there, its a double escape due to a 'check_url'.
Its line 248 of the 'image_captcha.module':
$img_src = check_url(url("image_captcha", $options));
For the sake of ease Ive change it to:
$img_src = url("image_captcha", $options);
Nothing earth-shattering but voila! It works again!
Comment #5
aohrvetpv commentedSolution in #4 may not be secure because without the call to
check_url(), the URL is never sanitized.This patch replaces the call to
check_url()withdrupal_strip_dangerous_protocols(). So, it is dropping a call tocheck_plain(), sincecheck_url()is justreturn check_plain(drupal_strip_dangerous_protocols($uri));. Thought is thattheme_image()performs the same operation ascheck_plain(). Not sure whether it is completely secure.This problem only seems to occur for me if the site has clean URLs disabled. So, another solution besides patching the code may be to enable clean URLs (for those who can).
Comment #6
shanes@tccompany.com commentedI can confirm that enabling clean URLs does resolve the issue for us. This was a migrated site, and we had clean URLs previously enabled, so enabling them again proved a viable solution.
Comment #7
aohrvetpv commentedPatch still needs review. Some sites will not be able to enable clean URLs.
Comment #8
chortlebuffer commentedI had the same problem and the clean url solution worked for me.
Comment #9
flaviovs commentedI have made a patch that introduces Simpletest tests to Image CAPTCHA (see #2468539: Image CAPTCHA test suite), and included a test for this issue. I confirm that the patch in #5 fix this issue. Image URL is now correct either with or without clean URLs.
Comment #10
hareshjhaveri commentedHi, I am not a developer. I added Captcha 7.x 1-3 and now I cannot even log in as an Administrator. I tried to disable it by renaming the module but it still ask me for the image code.
What can I do to disable it?
Comment #11
aohrvetpv commentedEdit: My mistake, I see now that your question is related to this issue.
hareshjhaveri, one way to disable the module is by directly changing its status in the database using SQL:
Or if you have Drush installed:
You may need to also disable the
captchamodule.Comment #12
wundo commentedComment #13
wundo commentedComment #16
barnystewart commentedI have been chasing down this problem and arrived at the same check_url() call as the source of the issue, but I would like to comment on the proposed solutions, which (I believe) ignore the underlying issue.
The fundamental problem is that the call to htmlspecialchars() within check_url() should not be called on a full string with html parameters being passed since the ampersand used to separate the arguments is a special html character and not simply an ampersand in a piece of text that needs to be escaped.
The reason that enabling clean urls works is simply because it makes the sid the first html argument and therefore it has no '&' before it, but if you look at the generated url the second html argument is still getting the ampersand escaped. It is only because sid is the first argument *and* the second argument is non-critical that this solution works.
The committed solution by AohRveTPV appears to be the best straight forward fix. The only possible improvement on this, as far as I can see, would be to call check_url() on the address portion of the url and on the individual html arguments. I do not know Drupal well enough to see a simple way to do this.
Comment #17
liquid-v commentedclean urls enabled, problem solved...
Comment #18
wescleyteixeira commented# 5 worked for me (and without clean url's)
Comment #19
capricorn1 commentedI had forgotten to renable clean URLs after an upgrade. Re-enabled clean URLs and it's working again.
Comment #20
Disco Jesus commentedwas able to run
UPDATE drup_system SET status=0 WHERE type='module' AND name='image_captcha';on my db, but still not able to log in.
found the table where all rendered challenges are store, found the last one and logged in.
noticed image captcha was disabled in drupal admin panel , in hind site a page refresh after executing sql command may have done the trick.
edit:
in hind hind site, even though disabled by SQL, image captcha was still selected as default captcha in the main captcha config, so even sending a kill command to the db prolly didn't work and IMHO the only way to get in is to copy and paste the last challenge code rendered