On some pages that have an encoded part in the url, like %FC
instead of ü
, I get a Uncaught URIError: URI malformed
error in the console and the captcha therefore is not working.
Our Project is iso-8859-1
encoded and there is nothing I can change about that.
Do you know a workaround that could fix this? I'm using reCAPTCHA 2.
My solution now is, that before the recaptcha/api.js
is executed, I grab the window.location.pathname
, get rid of the problematic elements and exchange it in the url with history.pushState
. If I'd simply changed the window.location.pathname
a page redirect would be the consequence.
Here is my example code:
var oldPath = window.location.pathname;
var newPath = decodeURIComponent( unescape( unescape(oldPath)));
var stateObj = {};
history.pushState(stateObj, "", newPath);