D
dino d.
hi - i'm building widget, and i'd like the user to be able to request
a new widget by clicking an ajax link in the widget itself. it
doesn't work, and i presume it's because of the built in xss
protection in browsers (to prove this to myself, i placed an html file
that contains the widget in the public directory of the widget server,
and this works fine).
however, recaptcha has managed to work around this, you add some
javascript to your page, and that javascript writes a captcha widget
into your form. in that widget, there is a 'request a new challenge'
link which works fine. it does exactly what i'm trying to do. - it
goes to the recaptcha server, renders a new widget, and replaces the
div of the widget, even though the page and the widget are from
different domains.
now, going through the code, they're doing something weird- the actual
code that you put in your web page looks like this:
var RecaptchaState = {
... //several variables
programming_error : '',
is_incorrect : false
};
document.write('<scr'+'ipt type="text/javascript" s'+'rc="' +
RecaptchaState.server + 'js/recaptcha.js"></scr'+'ipt>');
(function() {
var _recaptcha = document.createElement('script');
_recaptcha.type = 'text/javascript';
_recaptcha.async = true;
_recaptcha.src = (document.location.protocol == 'https:' ?
'https' : 'http') + '://www.google.com/recaptcha/api/challenge?
k=asdfasdfasdf (your key) &darklaunch=1'; //i've removed my key here
(document.getElementsByTagName('head')[0] ||
document.getElementsByTagName('body')[0]).appendChild(_recaptcha);
})();
somehow, this is tricking the browser into thinking that the widget is
the same source as the web site that is embedding it?
before i dig any deeper, does anyone know how to get around XSS
security precautions the way recaptcha does?
thanks,
dino
a new widget by clicking an ajax link in the widget itself. it
doesn't work, and i presume it's because of the built in xss
protection in browsers (to prove this to myself, i placed an html file
that contains the widget in the public directory of the widget server,
and this works fine).
however, recaptcha has managed to work around this, you add some
javascript to your page, and that javascript writes a captcha widget
into your form. in that widget, there is a 'request a new challenge'
link which works fine. it does exactly what i'm trying to do. - it
goes to the recaptcha server, renders a new widget, and replaces the
div of the widget, even though the page and the widget are from
different domains.
now, going through the code, they're doing something weird- the actual
code that you put in your web page looks like this:
var RecaptchaState = {
... //several variables
programming_error : '',
is_incorrect : false
};
document.write('<scr'+'ipt type="text/javascript" s'+'rc="' +
RecaptchaState.server + 'js/recaptcha.js"></scr'+'ipt>');
(function() {
var _recaptcha = document.createElement('script');
_recaptcha.type = 'text/javascript';
_recaptcha.async = true;
_recaptcha.src = (document.location.protocol == 'https:' ?
'https' : 'http') + '://www.google.com/recaptcha/api/challenge?
k=asdfasdfasdf (your key) &darklaunch=1'; //i've removed my key here
(document.getElementsByTagName('head')[0] ||
document.getElementsByTagName('body')[0]).appendChild(_recaptcha);
})();
somehow, this is tricking the browser into thinking that the widget is
the same source as the web site that is embedding it?
before i dig any deeper, does anyone know how to get around XSS
security precautions the way recaptcha does?
thanks,
dino