X-Git-Url: http://wagnertech.de/gitweb/gitweb.cgi/mfinanz.git/blobdiff_plain/bc1d6d175b170b8b71e16d9fc8d3e2af5be67425..c51050b4e3a115d0aa2bb070ab8537990f4b522f:/js/kivi.js diff --git a/js/kivi.js b/js/kivi.js index c6245c855..7fb250149 100644 --- a/js/kivi.js +++ b/js/kivi.js @@ -676,6 +676,29 @@ namespace("kivi", function(ns) { $input.prop('selectionStart', position); $input.prop('selectionEnd', position); }; + + ns._shell_escape = function(str) { + if (str.match(/^[a-zA-Z0-9.,_=+/-]+$/)) + return str; + + return "'" + str.replace(/'/, "'\\''") + "'"; + }; + + ns.call_as_curl = function(params) { + params = params || {}; + var uri = document.documentURI.replace(/\?.*/, ''); + var command = ['curl', '--user', kivi.myconfig.login + ':SECRET', '--request', params.method || 'POST'] + + $(params.data || []).each(function(idx, elt) { + command = command.concat([ '--form-string', elt.name + '=' + (elt.value || '') ]); + }); + + command.push(uri); + + return $.map(command, function(elt, idx) { + return kivi._shell_escape(elt); + }).join(' '); + }; }); kivi = namespace('kivi');