Problem/Motivation

There is an issue with the image captcha refresh link. Though its "href" parameter is correctly set with a starting slash, clicking on it will make a JS call with double slashes in the destination url. This might introduce issues in installations where htaccess rules to avoid these are not present. It would be nice to avoid adding any extra slash when creating the url.

Proposed resolution

Clean host and path from having slashes at their respective end/start and just add one in-between.

Remaining tasks

Upload patch.

Issue fork captcha-3109771

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

dpavon created an issue. See original summary.

dpavon’s picture

Here's a possible patch as a suggestion, though the JS specifics can be altered as long as we get a similar result.

dpavon’s picture

Issue summary: View changes
asmita26’s picture

Assigned: Unassigned » asmita26
asmita26’s picture

Assigned: asmita26 » Unassigned
Nick Dewitte’s picture

Without the patch, the XHR request made by the script is redirected to the correct URL.
This can cause issues when the requests are cached on the server, resulting in an eternal redirect loop, when the caching system ignores this double slash.

Re-rolled the patch since it wouldn't apply anymore.

spookyisland’s picture

Unfortunately my server doesn't redirect to the correct URL. This patch fixes the issue for me. Will you include it in the next version of the module?

Anybody’s picture

Issue tags: +Needs tests

Could we please have a test to prove this?

Anybody’s picture

@Nick Dewitte thanks, the patch in #6 looks good and correct. Could you create a MR from the patch and add tests to show it works as expected for cases where slashes are present or not?

Anybody’s picture

Status: Active » Needs work

For tests.

Grevil’s picture

Version: 8.x-1.x-dev » 2.x-dev
Anybody’s picture

Assigned: Unassigned » Grevil

@Grevil would you be so kind to add a little JavaScript enabled test for that link to reproduce the issue? With the change, it should be fixed. That way we can make safe it doesn't break again in the future.

You may also decide no test is needed and commit this as-is after manual testing. You decide.

Anybody’s picture

@Grevil: @thomas.frobieter just found a further bug with the image captcha reload functionality, so this generally needs tests.

Anybody’s picture

Status: Needs work » Needs review

Created a MR from #6 by @Nick Dewitte

Please review and add a test for the reload functionality.

Anybody’s picture

Grevil’s picture

Status: Needs review » Reviewed & tested by the community

Tested it manually, and it works great!

Added the test requirements in #3324399: Add more CAPTCHA test coverage, for when we have more time.

  • Grevil committed 83ded2b on 2.x authored by Anybody
    Issue #3109771: Image reload call adds additional slash
    
Grevil’s picture

Status: Reviewed & tested by the community » Fixed

Done.

Grevil’s picture

Priority: Minor » Normal
Status: Fixed » Needs work

Sorry, I don't know what I tested there yesterday, but this definitely breaks the image captcha refresh functionality...

I apologize.

Grevil’s picture

Priority: Normal » Major

  • Anybody committed 8e6daf6 on 2.x
    git commit -m 'Issue #3109771 by Anybody, Grevil, Nick Dewitte: Image...
Anybody’s picture

Status: Needs work » Needs review

const baseUrl = document.location.origin; was missing. No idea where that hat gone since the patch.

Please retest @Grevil! Already committed to 2.x

Grevil’s picture

Status: Needs review » Reviewed & tested by the community

Yep, fixed, thanks @Anybody!

Grevil’s picture

Status: Reviewed & tested by the community » Fixed

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.