]> 91.132.146.200 Git - insipid.git/commitdiff
fixed bug #8. Simple js check and extended validation on server side
authorBanana <mail@bananas-playground.net>
Sat, 12 Sep 2020 09:08:46 +0000 (11:08 +0200)
committerBanana <mail@bananas-playground.net>
Sat, 12 Sep 2020 09:08:46 +0000 (11:08 +0200)
ChangeLog
VERSION
webroot/asset/js/editlink.js
webroot/index.php
webroot/lib/summoner.class.php
webroot/view/editlink.php

index e3c73587ea75f633652fedf1a8052cc1dcc0fd0e..12c3bc9846ee3b623d9ed59a18ecd97f5a0c16bb 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,4 +1,11 @@
+version x.x.x - Darkmere ()
+
+    + Fixed bug #8 It is possible to add empty tags and categories.
+        Special chars check done on server side. JS has problems with unicode.
+
+
 version 2.5.1 - Caves of Circe (2020-03-22)
+
     + Bugfix release
 
 version 2.5 - Winnowing Hall (2020-03-21)
diff --git a/VERSION b/VERSION
index 7ad54034b88034a9644a7fa56bcdaec4aa5bbcaa..3826dabf5d1e00a58ba51254cad79a4668b234c2 100644 (file)
--- a/VERSION
+++ b/VERSION
@@ -1 +1 @@
-2.5.1 - Caves of Circe
+2.5.x - Darkmere
index 49cb769234774fde23f9a531a65d713fdfb8d212..6c10433ef7f0d23cb80dcee6ac5275b2ce4f6736 100644 (file)
@@ -32,7 +32,9 @@ function addTag(e,targetStartString) {
         let listBox = document.getElementById(targetStartString + '-listbox');
         let newTagTemplate = document.getElementById(targetStartString + '-template');
 
-        if(saveInput && listBox && elem && newTagTemplate) {
+        let checkString = _checkForSpaceString(elem.value,'nospace');
+
+        if(saveInput && listBox && elem && newTagTemplate && checkString) {
             let toAdd = elem.value;
             let newSaveValue = _appendToCommaString(saveInput.value,toAdd);
 
@@ -127,7 +129,19 @@ function _fillTagTemplate(el,newTagString,targetStartString) {
     let aEl = el.querySelector('a');
     aEl.setAttribute('onclick', "removeTag('"+newTagString+"','"+targetStartString+"');");
 
-
-
     return el;
-}
\ No newline at end of file
+}
+
+/**
+ * simple check if the string is empty or contains whitespace chars
+ * @param stringTocheck
+ * @returns {boolean}
+ * @private
+ */
+function _checkForSpaceString(stringTocheck) {
+    let check = stringTocheck.replace(/\s/gm,'');
+    if(check === stringTocheck && check.length > 0) {
+        return true;
+    }
+    return false;
+}
index ee276022a2eb14a2fa3d6f1dee977b0645c26dd7..7b6be3c1e5e7542e476ebf5e31167b79ff475bcd 100644 (file)
@@ -32,7 +32,7 @@ ini_set('error_reporting',-1); // E_ALL & E_STRICT
 # time settings
 date_default_timezone_set('Europe/Berlin');
 
-define('DEBUG',false);
+define('DEBUG',true);
 
 ## check request
 $_urlToParse = filter_var($_SERVER['QUERY_STRING'],FILTER_SANITIZE_STRING, FILTER_FLAG_STRIP_LOW);
index 845b8ba0c6fb6fd42d34600b8843efd3e9375542..ecb8c536d644be6420c561083ff5dc00693a5133 100644 (file)
@@ -385,34 +385,44 @@ class Summoner {
         */
        static function prepareTagOrCategoryStr($string) {
                $ret = array();
+        $_ret = array();
 
                $string = trim($string, ", ");
                if(strstr($string, ",")) {
                        $_t = explode(",", $string);
-                       foreach($_t as $new) {
-                               $ret[$new] = $new;
+                       foreach($_t as $n) {
+                               $_ret[$n] = $n;
                        }
                        unset($_t);
-                       unset($new);
+                       unset($n);
 
-                       foreach($ret as $e) {
+                       foreach($_ret as $e) {
                                if(strstr($e, " ")) {
                                        unset($ret[$e]);
                                        $_t = explode(" ", $e);
                                        foreach($_t as $new) {
                                                $new = trim($new);
-                                               if(!empty($new)) {
+                                               $_c = self::validate($new,'nospace');
+                                               if(!empty($new) && $_c === true) {
                                                        $ret[$new] = $new;
                                                }
                                        }
                                }
+                               else {
+                    $new = trim($e);
+                    $_c = self::validate($new,'nospace');
+                    if(!empty($new) && $_c === true) {
+                        $ret[$new] = $new;
+                    }
+                }
                        }
                }
                else {
                        $_t = explode(" ", $string);
                        foreach($_t as $new) {
                                $new = trim($new);
-                               if(!empty($new)) {
+                $_c = self::validate($new,'nospace');
+                               if(!empty($new) && $_c === true) {
                                   $ret[$new] = $new;
                                }
                        }
index 73b7b7b98902ae525d596aa45be156d4d88c6c59..712b7bf436077f3fcede21ca86c25ce952cb4b44 100644 (file)
                        <input type="text" placeholder="tagname"
                                                   name="taglistinput" list="tag-datalist" value="" onkeypress="addTag(event,'tag')" />
                                        </div>
-                                       <p class="help">Enter a new one or select an existing from the suggested and press enter.</p>
+                                       <p class="help">Enter a new one or select an existing from the suggested and press enter. Special chars check after save!</p>
                                </div>
                 <datalist id="tag-datalist">
                     <?php foreach($existingTags as $t) { ?>
                                                <input type="text" placeholder="categoryname"
                                                           name="categorylistinput" list="category-datalist" value="" onkeypress="addTag(event,'category')" />
                                        </div>
-                                       <p class="help">Enter a new one or select an existing from the suggested and press enter.</p>
+                                       <p class="help">Enter a new one or select an existing from the suggested and press enter. Special chars check after save!</p>
                                </div>
                                <datalist id="category-datalist">
                                        <?php foreach($existingCategories as $c) { ?>