From 87ecf0faf3243a234ae2e0d63baa6b9e637d6bc8 Mon Sep 17 00:00:00 2001 From: Piyush Mishra Date: Thu, 13 May 2021 01:12:50 +0530 Subject: [PATCH] bug fix --- src/validator.rs | 15 ++++++++++++++- src/ws_sansad/users.rs | 10 +++++----- static/img/github.svg | 1 + static/index.html | 16 +++++++--------- static/js/app.js | 6 +++--- 5 files changed, 30 insertions(+), 18 deletions(-) create mode 100644 static/img/github.svg diff --git a/src/validator.rs b/src/validator.rs index 4e90d5b..663217e 100644 --- a/src/validator.rs +++ b/src/validator.rs @@ -19,6 +19,7 @@ pub enum Validation { NoGupt, NoSpace, NoHashtag, + NoAndOrQuestion, } pub fn validate(val: Vec, dat: &str, entry_name: &str) -> Option { @@ -27,7 +28,8 @@ pub fn validate(val: Vec, dat: &str, entry_name: &str) -> Option non_empty(dat, entry_name), Validation::NoGupt => is_gupt(dat), Validation::NoSpace => no_space(dat, entry_name), - Validation::NoHashtag => no_hashtag(dat, entry_name) + Validation::NoHashtag => no_hashtag(dat, entry_name), + Validation::NoAndOrQuestion => no_and_or_question(dat, entry_name), }; if out != None { @@ -67,4 +69,15 @@ fn no_hashtag(dat: &str, entry_name: &str) -> Option { } else { None } +} + + +fn no_and_or_question(dat: &str, entry_name: &str) -> Option { + if dat.contains("&") { + Some(format!("{} shounld not have &", entry_name)) + } else if dat.contains("?") { + Some(format!("{} shounld not have ?", entry_name)) + } else { + None + } } \ No newline at end of file diff --git a/src/ws_sansad/users.rs b/src/ws_sansad/users.rs index 5c4141d..7b50f97 100644 --- a/src/ws_sansad/users.rs +++ b/src/ws_sansad/users.rs @@ -63,10 +63,10 @@ impl WsSansad { }; // Validate - if let Some(val ) = validate(vec![vl::NonEmpty, vl::NoSpace, vl::NoHashtag], &kunjika, "Kunjika") { + if let Some(val ) = validate(vec![vl::NonEmpty, vl::NoSpace, vl::NoHashtag, vl::NoAndOrQuestion], &kunjika, "Kunjika") { self.send_err_response(&val); return; - } else if let Some(val ) = validate(vec![vl::NonEmpty], &name, "Name") { + } else if let Some(val ) = validate(vec![vl::NonEmpty, vl::NoAndOrQuestion], &name, "Name") { self.send_err_response(&val); return; } @@ -183,13 +183,13 @@ impl WsSansad { // Validate - if let Some(val ) = validate(vec![vl::NonEmpty, vl::NoGupt, vl::NoSpace], &kaksh_kunjika, "Kaksh Kunjika") { + if let Some(val ) = validate(vec![vl::NonEmpty, vl::NoGupt, vl::NoSpace, vl::NoAndOrQuestion], &kaksh_kunjika, "Kaksh Kunjika") { self.send_err_response(&val); return; - } else if let Some(val ) = validate(vec![vl::NonEmpty, vl::NoSpace, vl::NoHashtag], &kunjika, "Kunjika") { + } else if let Some(val ) = validate(vec![vl::NonEmpty, vl::NoSpace, vl::NoHashtag, vl::NoAndOrQuestion], &kunjika, "Kunjika") { self.send_err_response(&val); return; - } else if let Some(val ) = validate(vec![vl::NonEmpty], &name, "Name") { + } else if let Some(val ) = validate(vec![vl::NonEmpty, vl::NoAndOrQuestion], &name, "Name") { self.send_err_response(&val); return; } diff --git a/static/img/github.svg b/static/img/github.svg new file mode 100644 index 0000000..8d823e3 --- /dev/null +++ b/static/img/github.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/static/index.html b/static/index.html index d4b84e7..b2266c0 100644 --- a/static/index.html +++ b/static/index.html @@ -97,17 +97,15 @@
- - By tapping "Connect" button I agree with - Terms of Service and - Privacy Policy - +
By tapping "Connect" button I agree with Terms of Service and Privacy Policy
- - +
+
Made with ❤️️ by  Piyush Mishra
+
+
+ GitHub +
diff --git a/static/js/app.js b/static/js/app.js index 64d7084..dedebef 100644 --- a/static/js/app.js +++ b/static/js/app.js @@ -153,9 +153,9 @@ function connect(frm) { //push url var frm = $('form[name=kaksh_sec]'); - var url = '/?' + frm.find('[name=kaksh_kunjika]').val() + '&' + - frm.find('[name=kunjika]').val() + '&' + - frm.find('[name=name]').val(); + var url = '/?' + encodeURI(frm.find('[name=kaksh_kunjika]').val()) + '&' + + encodeURI(frm.find('[name=kunjika]').val()) + '&' + + encodeURI(frm.find('[name=name]').val()); history.pushState({}, 'Lupt Chat', url); socket.send(JSON.stringify({cmd: 'list'}));