webssh

Web based ssh client https://github.com/huashengdun/webssh webssh.huashengdun.org/
git clone http://git.hanabi.in/repos/webssh.git
Log | Files | Refs | README | LICENSE

commit 8eb636d73b181f5b72401b3b9afde3bd78679581
parent bbb7d79b2ae371122a803c66fbee12d129983f90
Author: Sheng <webmaster0115@gmail.com>
Date:   Sun,  9 Sep 2018 15:21:13 +0800

Normalize data before validating it

Diffstat:
Mwebssh/static/js/main.js | 23++++++++++++++++++++++-
1 file changed, 22 insertions(+), 1 deletion(-)

diff --git a/webssh/static/js/main.js b/webssh/static/js/main.js @@ -297,17 +297,38 @@ jQuery(function($){ } - function wrap_object(opts){ + function wrap_object(opts) { var obj = {}; obj.get = function(attr) { return opts[attr] || ''; }; + + obj.set = function(attr, val) { + opts[attr] = val; + }; + return obj; } + function normalize_data(data) { + var i, attr, val; + var attrs = fields.concat('privatekey'); + + for (i = 0; i < attrs.length; i++) { + attr = attrs[i]; + val = data.get(attr); + if (typeof val === 'string') { + data.set(attr, val.trim()); + } + } + } + + function validate_form_data(data) { + normalize_data(data); + var hostname = data.get('hostname'), port = data.get('port'), username = data.get('username'),