# HG changeset patch # User Dan # Date 1235961848 18000 # Node ID c8fc1493eacd65e0653528e2d90515861a70268c # Parent 4f85ab095cc8d3170a03d357b0d8765bfe61b6cd Fixed a few issues with input postprocessing in client API diff -r 4f85ab095cc8 -r c8fc1493eacd plugins/yubikey/yubikey.js --- a/plugins/yubikey/yubikey.js Sun Mar 01 20:41:27 2009 -0500 +++ b/plugins/yubikey/yubikey.js Sun Mar 01 21:44:08 2009 -0500 @@ -55,7 +55,7 @@ window.clearInterval(yk_interval); miniPromptDestroy(this); } - else if ( this.value.length == 44 && !this.submitted ) + else if ( this.value.length >= 44 && !this.submitted ) { this.submitted = true; yk_handle_submit(this); @@ -64,7 +64,7 @@ { $('div.yubikey_bar > img', this.parentNode) .css('width', String(this.value.length * 2) + 'px') - .css('background-position', String(this.value.length - 44) + 'px -88px'); + .css('background-position', String((this.value.length > 44 ? 44 : this.value.length) - 44) + 'px -88px'); } e.preventDefault(); e.stopPropagation(); @@ -86,13 +86,26 @@ function yk_handle_submit(ta) { - if ( !ta.value.match(/^[cbdefghijklnrtuv]{44}$/) ) + if ( ta.value.length > 44 || !ta.value.match(/^[cbdefghijklnrtuv]+$/) ) { setTimeout(function() { - yk_mb_construct(ta.parentNode); + var parent = ta.parentNode; + var tabackup = { + field_id: ta.yk_field_id, + status_id: ta.yk_status_id, + submit_func: ta.submit_func + }; + yk_mb_construct(parent); + var input = parent.getElementsByTagName('input')[0]; + if ( tabackup.field_id ) + input.yk_field_id = tabackup.field_id; + if ( tabackup.status_id ) + input.yk_status_id = tabackup.status_id; + if ( tabackup.submit_func ) + input.submit_func = tabackup.submit_func; }, 1000); - $('h3', ta.parentNode).text($lang.get('yubiauth_msg_invalid_chars')); + $('h3', ta.parentNode).text($lang.get(ta.value.length > 44 ? 'yubiauth_msg_too_long' : 'yubiauth_msg_invalid_chars')); $('div.yubikey_bar > img', this.parentNode).addClass('yubikey_bar_error'); return false; }