CVE-2021-41086 (published 2021-09-21T21:15Z)

jsuites is an open source collection of common required javascript web components. In affected versions users are subject to cross site scripting (XSS) attacks via clipboard content. jsuites is vulnerable to DOM based XSS if the user can be tricked into copying _anything_ from a malicious and pasting it into the html editor. This is because a part of the clipboard content is directly written to `innerHTML` allowing for javascript injection and thus XSS. Users are advised to update to version 4.9.11 to resolve.

Severity: LOW
CVSS v2 base score: 3.5 (AV:N/AC:M/Au:S/C:N/I:P/A:N)
CVSS v3 base score: 5.4, MEDIUM (CVSS:3.1/AV:N/AC:L/PR:L/UI:R/S:C/C:L/I:L/A:N)

Weakness information:
cwe_id: CWE-79
cwe_name: Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')
description: The product does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.
extended_description: 
            Cross-site scripting (XSS) vulnerabilities occur when:
            
               Untrusted data enters a web application, typically from a web request.
               The web application dynamically generates a web page that contains this untrusted data.
               During page generation, the application does not prevent the data from containing content that is executable by a web browser, such as JavaScript, HTML tags, HTML attributes, mouse events, Flash, ActiveX, etc.
               A victim visits the generated web page through a web browser, which contains malicious script that was injected using the untrusted data.
               Since the script comes from a web page that was sent by the web server, the victim's web browser executes the malicious script in the context of the web server's domain.
               This effectively violates the intention of the web browser's same-origin policy, which states that scripts in one domain should not be able to access resources or run code in a different domain.
            
            There are three main kinds of XSS:
            
               
                  Type 1: Reflected XSS (or Non-Persistent) - 
         			The server reads data directly from the HTTP request and reflects it back in the HTTP response. Reflected XSS exploits occur when an attacker causes a victim to supply dangerous content to a vulnerable web application, which is then reflected back to the victim and executed by the web browser. The most common mechanism for delivering malicious content is to include it as a parameter in a URL that is posted publicly or e-mailed directly to the victim. URLs constructed in this manner constitute the core of many phishing schemes, whereby an attacker convinces a victim to visit a URL that refers to a vulnerable site. After the site reflects the attacker's content back to the victim, the content is executed by the victim's browser.
               
                  Type 2: Stored XSS (or Persistent) - 
               The application stores dangerous data in a database, message forum, visitor log, or other trusted data store. At a later time, the dangerous data is subsequently read back into the application and included in dynamic content. From an attacker's perspective, the optimal place to inject malicious content is in an area that is displayed to either many users or particularly interesting users. Interesting users typically have elevated privileges in the application or interact with sensitive data that is valuable to the attacker. If one of these users executes malicious content, the attacker may be able to perform privileged operations on behalf of the user or gain access to sensitive data belonging to the user. For example, the attacker might inject XSS into a log message, which might not be handled properly when an administrator views the logs.
            
               
                  Type 0: DOM-Based XSS - 
               In DOM-based XSS, the client performs the injection of XSS into the page; in the other types, the server performs the injection. DOM-based XSS generally involves server-controlled, trusted script that is sent to the client, such as Javascript that performs sanity checks on a form before the user submits it. If the server-supplied script processes user-supplied data and then injects it back into the web page (such as with dynamic HTML), then DOM-based XSS is possible.
            
            
            Once the malicious script is injected, the attacker can perform a variety of malicious activities. The attacker could transfer private information, such as cookies that may include session information, from the victim's machine to the attacker. The attacker could send malicious requests to a web site on behalf of the victim, which could be especially dangerous to the site if the victim has administrator privileges to manage that site. Phishing attacks could be used to emulate trusted web sites and trick the victim into entering a password, allowing the attacker to compromise the victim's account on that web site. Finally, the script could exploit a vulnerability in the web browser itself possibly taking over the victim's machine, sometimes referred to as "drive-by hacking."
            In many cases, the attack can be launched without the victim even being aware of it. Even with careful users, attackers frequently use a variety of methods to encode the malicious portion of the attack, such as URL encoding or Unicode, so the request looks less suspicious.
         
         

Fix information:
repo_url: https://github.com/jsuites/jsuites
commit_details: repo_url: https://github.com/jsuites/jsuites
author: =
author_date: 2021-09-18 16:58:49+01:00
msg: Editor sec fix, toolbar reponsiveness tracking fix, responsive
contextmenu. v4.9.10
repository: repo_url: https://github.com/jsuites/jsuites
repo_name: jsuites/jsuites
description: jSuites is a collection of lightweight common required javascript web components. It is composed of fully responsive vanilla plugins to help you bring the best user experience to your projects, independent of the platform. Same JS codebase across different platforms.
repo_language: JavaScript
owner: jsuites
file_changes: filename: jsuites.basic.css
change_type: ModificationType.MODIFY
diff: @@ -840,6 +840,40 @@
   pointer-events: auto;
 }
 
+@media only screen and (max-width: 420px) {
+    .jcontextmenu {
+        top: initial !important;
+        left: 0px !important;
+        bottom: 0px !important;
+        width: 100vw;
+        height: 260px;
+        overflow: scroll;
+        animation: slide-bottom-in 0.4s forwards;
+    }
+    .jcontextmenu div {
+        width: 100%;
+        text-align: center;
+        border-bottom: 1px solid #ccc;
+        padding: 15px;
+    }
+    .jcontextmenu > div::before {
+        display: none;
+    }
+    .jcontextmenu a {
+        font-size: 1.4em;
+        text-transform: uppercase;
+    }
+    .jcontextmenu span {
+        display: none;
+    }
+    .jcontextmenu span {
+        display: none;
+    }
+    .jcontextmenu hr {
+        display: none;
+    }
+}
+
 .jdropdown {
     cursor:pointer;
     -webkit-touch-callout: none;

programming_language: CSS
filename: jsuites.basic.js
change_type: ModificationType.MODIFY
diff: @@ -17,7 +17,7 @@
 
 var jSuites = function(options) {
     var obj = {}
-    var version = '4.9.9';
+    var version = '4.4.0';
 
     var find = function(DOMElement, component) {
         if (DOMElement[component.type] && DOMElement[component.type] == component) {
@@ -5271,7 +5271,7 @@ jSuites.editor = (function(el, options) {
     }
 
     // Elements to be removed
-    var remove = [HTMLUnknownElement];
+    var remove = [HTMLUnknownElement,HTMLAudioElement,HTMLEmbedElement,HTMLIFrameElement,HTMLTextAreaElement,HTMLInputElement,HTMLScriptElement];
 
     // Valid CSS attributes
     var validStyle = ['color', 'font-weight', 'font-size', 'background', 'background-color', 'margin'];
@@ -5296,9 +5296,9 @@ jSuites.editor = (function(el, options) {
                }
            }
            // Process image
-           if (element.tagName == 'IMG') {
+           if (element.tagName.toUpperCase() == 'IMG') {
                if (! obj.options.acceptImages) {
-                   element.remove();
+                   element.parentNode.removeChild(element);
                } else {
                    // Check if is data
                    element.setAttribute('tabindex', '900');
@@ -5334,9 +5334,11 @@ jSuites.editor = (function(el, options) {
         if (data) {
             data = data.replace(new RegExp('<!--(.*?)-->', 'gsi'), '');
         }
+        var parser = new DOMParser();
+        var d = parser.parseFromString(data, "text/html");
+        parse(d);
         var span = document.createElement('span');
-        span.innerHTML = data;
-        parse(span);
+        span.innerHTML = d.firstChild.innerHTML;
         return span;
     } 
 
@@ -9114,7 +9116,8 @@ jSuites.tabs = (function(el, options) {
 });
 
 jSuites.toolbar = (function(el, options) {
-    var obj = {};
+    // New instance
+    var obj = { type:'toolbar' };
     obj.options = {};
 
     // Default configuration
@@ -9124,6 +9127,7 @@ jSuites.toolbar = (function(el, options) {
         badge: false,
         title: false,
         responsive: false,
+        maxWidth: null,
         items: [],
     }
 
@@ -9322,16 +9326,21 @@ jSuites.toolbar = (function(el, options) {
 
     obj.refresh = function() {
         if (obj.options.responsive == true) {
+            // Width of the c
+            var rect = el.parentNode.getBoundingClientRect();
+            if (! obj.options.maxWidth) {
+                obj.options.maxWidth = rect.width;
+            }
+            // Max width
+            var width = parseInt(obj.options.maxWidth); 
             // Remove arrow
             toolbarArrow.remove();
             // Move all items to the toolbar
             while (toolbarFloating.firstChild) {
                 toolbarContent.appendChild(toolbarFloating.firstChild);
             }
-            // Width of the c
-            var rect = el.parentNode.getBoundingClientRect();
             // Available parent space
-            var available = rect.width;
+            var available = obj.options.maxWidth;
             // Toolbar is larger than the parent, move elements to the floating element
             if (available < toolbarContent.offsetWidth) {
                 // Give space to the floating element

programming_language: JavaScript
filename: jsuites.css
change_type: ModificationType.MODIFY
diff: @@ -840,6 +840,40 @@
   pointer-events: auto;
 }
 
+@media only screen and (max-width: 420px) {
+    .jcontextmenu {
+        top: initial !important;
+        left: 0px !important;
+        bottom: 0px !important;
+        width: 100vw;
+        height: 260px;
+        overflow: scroll;
+        animation: slide-bottom-in 0.4s forwards;
+    }
+    .jcontextmenu div {
+        width: 100%;
+        text-align: center;
+        border-bottom: 1px solid #ccc;
+        padding: 15px;
+    }
+    .jcontextmenu > div::before {
+        display: none;
+    }
+    .jcontextmenu a {
+        font-size: 1.4em;
+        text-transform: uppercase;
+    }
+    .jcontextmenu span {
+        display: none;
+    }
+    .jcontextmenu span {
+        display: none;
+    }
+    .jcontextmenu hr {
+        display: none;
+    }
+}
+
 .jdropdown {
     cursor:pointer;
     -webkit-touch-callout: none;

programming_language: CSS
filename: jsuites.js
change_type: ModificationType.MODIFY
diff: @@ -17,7 +17,7 @@
 
 var jSuites = function(options) {
     var obj = {}
-    var version = '4.9.9';
+    var version = '4.4.0';
 
     var find = function(DOMElement, component) {
         if (DOMElement[component.type] && DOMElement[component.type] == component) {
@@ -5282,7 +5282,7 @@ jSuites.editor = (function(el, options) {
     }
 
     // Elements to be removed
-    var remove = [HTMLUnknownElement];
+    var remove = [HTMLUnknownElement,HTMLAudioElement,HTMLEmbedElement,HTMLIFrameElement,HTMLTextAreaElement,HTMLInputElement,HTMLScriptElement];
 
     // Valid CSS attributes
     var validStyle = ['color', 'font-weight', 'font-size', 'background', 'background-color', 'margin'];
@@ -5307,9 +5307,9 @@ jSuites.editor = (function(el, options) {
                }
            }
            // Process image
-           if (element.tagName == 'IMG') {
+           if (element.tagName.toUpperCase() == 'IMG') {
                if (! obj.options.acceptImages) {
-                   element.remove();
+                   element.parentNode.removeChild(element);
                } else {
                    // Check if is data
                    element.setAttribute('tabindex', '900');
@@ -5345,9 +5345,11 @@ jSuites.editor = (function(el, options) {
         if (data) {
             data = data.replace(new RegExp('<!--(.*?)-->', 'gsi'), '');
         }
+        var parser = new DOMParser();
+        var d = parser.parseFromString(data, "text/html");
+        parse(d);
         var span = document.createElement('span');
-        span.innerHTML = data;
-        parse(span);
+        span.innerHTML = d.firstChild.innerHTML;
         return span;
     } 
 
@@ -11019,7 +11021,8 @@ jSuites.tags = (function(el, options) {
 });
 
 jSuites.toolbar = (function(el, options) {
-    var obj = {};
+    // New instance
+    var obj = { type:'toolbar' };
     obj.options = {};
 
     // Default configuration
@@ -11029,6 +11032,7 @@ jSuites.toolbar = (function(el, options) {
         badge: false,
         title: false,
         responsive: false,
+        maxWidth: null,
         items: [],
     }
 
@@ -11227,16 +11231,21 @@ jSuites.toolbar = (function(el, options) {
 
     obj.refresh = function() {
         if (obj.options.responsive == true) {
+            // Width of the c
+            var rect = el.parentNode.getBoundingClientRect();
+            if (! obj.options.maxWidth) {
+                obj.options.maxWidth = rect.width;
+            }
+            // Max width
+            var width = parseInt(obj.options.maxWidth); 
             // Remove arrow
             toolbarArrow.remove();
             // Move all items to the toolbar
             while (toolbarFloating.firstChild) {
                 toolbarContent.appendChild(toolbarFloating.firstChild);
             }
-            // Width of the c
-            var rect = el.parentNode.getBoundingClientRect();
             // Available parent space
-            var available = rect.width;
+            var available = obj.options.maxWidth;
             // Toolbar is larger than the parent, move elements to the floating element
             if (available < toolbarContent.offsetWidth) {
                 // Give space to the floating element

programming_language: JavaScript
filename: package.json
change_type: ModificationType.MODIFY
diff: @@ -19,7 +19,7 @@
         "javascript plugins"
     ],
     "main": "dist/jsuites.js",
-    "version": "4.9.9",
+    "version": "4.9.10",
     "bugs": "https://github.com/jsuites/jsuites/issues",
     "homepage": "https://github.com/jsuites/jsuites",
     "docs": "https://jsuites.net",

programming_language: Markdown
filename: contextmenu.css
change_type: ModificationType.MODIFY
diff: @@ -95,4 +95,38 @@
   -webkit-transform: translate(0, 0) scale(1);
   transform: translate(0, 0) scale(1);
   pointer-events: auto;
+}
+
+@media only screen and (max-width: 420px) {
+    .jcontextmenu {
+        top: initial !important;
+        left: 0px !important;
+        bottom: 0px !important;
+        width: 100vw;
+        height: 260px;
+        overflow: scroll;
+        animation: slide-bottom-in 0.4s forwards;
+    }
+    .jcontextmenu div {
+        width: 100%;
+        text-align: center;
+        border-bottom: 1px solid #ccc;
+        padding: 15px;
+    }
+    .jcontextmenu > div::before {
+        display: none;
+    }
+    .jcontextmenu a {
+        font-size: 1.4em;
+        text-transform: uppercase;
+    }
+    .jcontextmenu span {
+        display: none;
+    }
+    .jcontextmenu span {
+        display: none;
+    }
+    .jcontextmenu hr {
+        display: none;
+    }
 }
\ No newline at end of file

programming_language: CSS
filename: editor.js
change_type: ModificationType.MODIFY
diff: @@ -724,7 +724,7 @@ jSuites.editor = (function(el, options) {
     }
 
     // Elements to be removed
-    var remove = [HTMLUnknownElement];
+    var remove = [HTMLUnknownElement,HTMLAudioElement,HTMLEmbedElement,HTMLIFrameElement,HTMLTextAreaElement,HTMLInputElement,HTMLScriptElement];
 
     // Valid CSS attributes
     var validStyle = ['color', 'font-weight', 'font-size', 'background', 'background-color', 'margin'];
@@ -749,9 +749,9 @@ jSuites.editor = (function(el, options) {
                }
            }
            // Process image
-           if (element.tagName == 'IMG') {
+           if (element.tagName.toUpperCase() == 'IMG') {
                if (! obj.options.acceptImages) {
-                   element.remove();
+                   element.parentNode.removeChild(element);
                } else {
                    // Check if is data
                    element.setAttribute('tabindex', '900');
@@ -787,9 +787,11 @@ jSuites.editor = (function(el, options) {
         if (data) {
             data = data.replace(new RegExp('<!--(.*?)-->', 'gsi'), '');
         }
+        var parser = new DOMParser();
+        var d = parser.parseFromString(data, "text/html");
+        parse(d);
         var span = document.createElement('span');
-        span.innerHTML = data;
-        parse(span);
+        span.innerHTML = d.firstChild.innerHTML;
         return span;
     } 
 

programming_language: JavaScript
filename: toolbar.js
change_type: ModificationType.MODIFY
diff: @@ -1,5 +1,6 @@
 jSuites.toolbar = (function(el, options) {
-    var obj = {};
+    // New instance
+    var obj = { type:'toolbar' };
     obj.options = {};
 
     // Default configuration
@@ -9,6 +10,7 @@ jSuites.toolbar = (function(el, options) {
         badge: false,
         title: false,
         responsive: false,
+        maxWidth: null,
         items: [],
     }
 
@@ -207,16 +209,21 @@ jSuites.toolbar = (function(el, options) {
 
     obj.refresh = function() {
         if (obj.options.responsive == true) {
+            // Width of the c
+            var rect = el.parentNode.getBoundingClientRect();
+            if (! obj.options.maxWidth) {
+                obj.options.maxWidth = rect.width;
+            }
+            // Max width
+            var width = parseInt(obj.options.maxWidth); 
             // Remove arrow
             toolbarArrow.remove();
             // Move all items to the toolbar
             while (toolbarFloating.firstChild) {
                 toolbarContent.appendChild(toolbarFloating.firstChild);
             }
-            // Width of the c
-            var rect = el.parentNode.getBoundingClientRect();
             // Available parent space
-            var available = rect.width;
+            var available = obj.options.maxWidth;
             // Toolbar is larger than the parent, move elements to the floating element
             if (available < toolbarContent.offsetWidth) {
                 // Give space to the floating element

programming_language: JavaScript
repo_url: https://github.com/jsuites/jsuites
commit_details: repo_url: https://github.com/jsuites/jsuites
author: =
author_date: 2021-09-18 19:31:24+01:00
msg: Editor sanitize parser updates.
repository: repo_url: https://github.com/jsuites/jsuites
repo_name: jsuites/jsuites
description: jSuites is a collection of lightweight common required javascript web components. It is composed of fully responsive vanilla plugins to help you bring the best user experience to your projects, independent of the platform. Same JS codebase across different platforms.
repo_language: JavaScript
owner: jsuites
file_changes: filename: jsuites.basic.js
change_type: ModificationType.MODIFY
diff: @@ -17,7 +17,7 @@
 
 var jSuites = function(options) {
     var obj = {}
-    var version = '4.4.0';
+    var version = '4.9.11';
 
     var find = function(DOMElement, component) {
         if (DOMElement[component.type] && DOMElement[component.type] == component) {
@@ -4999,6 +4999,10 @@ jSuites.editor = (function(el, options) {
     }
 
     obj.addImage = function(src, asSnippet) {
+        if (! src) {
+            src = '';
+        }
+
         if (src.substr(0,4) != 'data' && ! obj.options.remoteParser) {
             console.error('remoteParser not defined in your initialization');
         } else {
@@ -5273,6 +5277,9 @@ jSuites.editor = (function(el, options) {
     // Elements to be removed
     var remove = [HTMLUnknownElement,HTMLAudioElement,HTMLEmbedElement,HTMLIFrameElement,HTMLTextAreaElement,HTMLInputElement,HTMLScriptElement];
 
+    // Valid properties
+    var validProperty = ['width', 'height', 'align', 'border', 'src', 'tabindex'];
+
     // Valid CSS attributes
     var validStyle = ['color', 'font-weight', 'font-size', 'background', 'background-color', 'margin'];
 
@@ -5297,7 +5304,7 @@ jSuites.editor = (function(el, options) {
            }
            // Process image
            if (element.tagName.toUpperCase() == 'IMG') {
-               if (! obj.options.acceptImages) {
+               if (! obj.options.acceptImages || ! element.src) {
                    element.parentNode.removeChild(element);
                } else {
                    // Check if is data
@@ -5305,12 +5312,19 @@ jSuites.editor = (function(el, options) {
                    // Check attributes for persistance
                    obj.addImage(element.src);
                }
-           } else {
-               // Remove attributes
-               var numAttributes = element.attributes.length - 1;
+           }
+           // Remove attributes
+           var attr = [];
+           var numAttributes = element.attributes.length - 1;
+           if (numAttributes > 0) {
                for (var i = numAttributes; i >= 0 ; i--) {
-                   element.removeAttribute(element.attributes[i].name);
+                   attr.push(element.attributes[i].name);
                }
+               attr.forEach(function(v) {
+                   if (validProperty.indexOf(v) == -1) {
+                       element.removeAttribute(v);
+                   }
+               });
            }
            element.style = '';
            // Add valid style

programming_language: JavaScript
filename: jsuites.js
change_type: ModificationType.MODIFY
diff: @@ -17,7 +17,7 @@
 
 var jSuites = function(options) {
     var obj = {}
-    var version = '4.4.0';
+    var version = '4.9.11';
 
     var find = function(DOMElement, component) {
         if (DOMElement[component.type] && DOMElement[component.type] == component) {
@@ -5010,6 +5010,10 @@ jSuites.editor = (function(el, options) {
     }
 
     obj.addImage = function(src, asSnippet) {
+        if (! src) {
+            src = '';
+        }
+
         if (src.substr(0,4) != 'data' && ! obj.options.remoteParser) {
             console.error('remoteParser not defined in your initialization');
         } else {
@@ -5284,6 +5288,9 @@ jSuites.editor = (function(el, options) {
     // Elements to be removed
     var remove = [HTMLUnknownElement,HTMLAudioElement,HTMLEmbedElement,HTMLIFrameElement,HTMLTextAreaElement,HTMLInputElement,HTMLScriptElement];
 
+    // Valid properties
+    var validProperty = ['width', 'height', 'align', 'border', 'src', 'tabindex'];
+
     // Valid CSS attributes
     var validStyle = ['color', 'font-weight', 'font-size', 'background', 'background-color', 'margin'];
 
@@ -5308,7 +5315,7 @@ jSuites.editor = (function(el, options) {
            }
            // Process image
            if (element.tagName.toUpperCase() == 'IMG') {
-               if (! obj.options.acceptImages) {
+               if (! obj.options.acceptImages || ! element.src) {
                    element.parentNode.removeChild(element);
                } else {
                    // Check if is data
@@ -5316,12 +5323,19 @@ jSuites.editor = (function(el, options) {
                    // Check attributes for persistance
                    obj.addImage(element.src);
                }
-           } else {
-               // Remove attributes
-               var numAttributes = element.attributes.length - 1;
+           }
+           // Remove attributes
+           var attr = [];
+           var numAttributes = element.attributes.length - 1;
+           if (numAttributes > 0) {
                for (var i = numAttributes; i >= 0 ; i--) {
-                   element.removeAttribute(element.attributes[i].name);
+                   attr.push(element.attributes[i].name);
                }
+               attr.forEach(function(v) {
+                   if (validProperty.indexOf(v) == -1) {
+                       element.removeAttribute(v);
+                   }
+               });
            }
            element.style = '';
            // Add valid style

programming_language: JavaScript
filename: jsuites.layout.css
change_type: ModificationType.MODIFY
diff: @@ -1588,6 +1588,7 @@ section.middle {
 
 .jmenu a:hover, .jmenu a.selected {
     text-decoration: underline;
+    font-weight: bold;
 }
 
 .jmenu .title {

programming_language: CSS
filename: jsuites.layout.js
change_type: ModificationType.MODIFY
diff: @@ -1701,7 +1701,7 @@ jSuites.menu = (function(el, options) {
                 menu[i].classList.remove('selected');
                 if (menu[i].getAttribute('data-id')) {
                     var state = localStorage.getItem('jmenu-' + menu[i].getAttribute('data-id'));
-                    if (state === null || state == 1) {
+                    if (state == 1) {
                         menu[i].classList.add('selected');
                     }
                 }
@@ -1716,48 +1716,59 @@ jSuites.menu = (function(el, options) {
         }
     }
 
-    obj.select = function(o) {
-        var menu = el.querySelectorAll('nav a');
-        for (var i = 0; i < menu.length; i++) {
-            menu[i].classList.remove('selected');
-        }
-        o.classList.add('selected');
-
-        // Better navigation
-        if (options && options.collapse == true) {
-            if (o.classList.contains('show')) {
-                menu = el.querySelectorAll('nav');
-                for (var i = 0; i < menu.length; i++) {
-                    menu[i].style.display = '';
-                }
-                o.style.display = 'none';
-            } else {
-                menu = el.querySelectorAll('nav');
-                for (var i = 0; i < menu.length; i++) {
-                    menu[i].style.display = 'none';
-                }
+    obj.select = function(o, e) {
+        if (o.tagName == 'NAV') {
+            var m = el.querySelectorAll('nav');
+            for (var i = 0; i < m.length; i++) {
+                m[i].style.display = 'none';
+            }
+            o.style.display = '';
+            o.classList.add('selected');
+        } else {
+            var m = el.querySelectorAll('nav a');
+            for (var i = 0; i < m.length; i++) {
+                m[i].classList.remove('selected');
+            }
+            o.classList.add('selected');
+
+            // Better navigation
+            if (options && options.collapse == true) {
+                if (o.classList.contains('show')) {
+                    m = el.querySelectorAll('nav');
+                    for (var i = 0; i < m.length; i++) {
+                        m[i].style.display = '';
+                    }
+                    o.style.display = 'none';
+                } else {
+                    m = el.querySelectorAll('nav');
+                    for (var i = 0; i < m.length; i++) {
+                        m[i].style.display = 'none';
+                    }
 
-                menu = el.querySelector('.show');
-                if (menu) {
-                    menu.style.display = 'block';
-                }
+                    m = el.querySelector('.show');
+                    if (m) {
+                        m.style.display = 'block';
+                    }
 
-                menu = jSuites.findElement(o.parentNode, 'selected');
-                if (menu) {
-                    menu.style.display = '';
+                    m = jSuites.findElement(o.parentNode, 'selected');
+                    if (m) {
+                        m.style.display = '';
+                    }
                 }
             }
         }
 
+        if (options && typeof(options.onclick) == 'function') {
+            options.onclick(obj, e);
+        }
+
         // Close menu if is oped
         if (jSuites.getWindowWidth() < 800) {
-            setTimeout(function() {
-                obj.hide();
-            }, 0);
+            obj.hide();
         }
     }
 
-    var actionDown = function(e) {
+    var action = function(e) {
         if (e.target.tagName == 'H2') {
             if (e.target.parentNode.classList.contains('selected')) {
                 e.target.parentNode.classList.remove('selected');
@@ -1768,14 +1779,14 @@ jSuites.menu = (function(el, options) {
             }
         } else if (e.target.tagName == 'A') {
             // Mark link as selected
-            obj.select(e.target);
+            obj.select(e.target, e);
         }
     }
 
     if ('ontouchstart' in document.documentElement === true) {
-        el.addEventListener('touchstart', actionDown);
+        el.addEventListener('touchsend', action);
     } else {
-        el.addEventListener('mousedown', actionDown);
+        el.addEventListener('mouseup', action);
     }
 
     // Add close action

programming_language: JavaScript
filename: package.json
change_type: ModificationType.MODIFY
diff: @@ -19,7 +19,7 @@
         "javascript plugins"
     ],
     "main": "dist/jsuites.js",
-    "version": "4.9.10",
+    "version": "4.9.11",
     "bugs": "https://github.com/jsuites/jsuites/issues",
     "homepage": "https://github.com/jsuites/jsuites",
     "docs": "https://jsuites.net",

programming_language: Markdown
filename: editor.js
change_type: ModificationType.MODIFY
diff: @@ -452,6 +452,10 @@ jSuites.editor = (function(el, options) {
     }
 
     obj.addImage = function(src, asSnippet) {
+        if (! src) {
+            src = '';
+        }
+
         if (src.substr(0,4) != 'data' && ! obj.options.remoteParser) {
             console.error('remoteParser not defined in your initialization');
         } else {
@@ -726,6 +730,9 @@ jSuites.editor = (function(el, options) {
     // Elements to be removed
     var remove = [HTMLUnknownElement,HTMLAudioElement,HTMLEmbedElement,HTMLIFrameElement,HTMLTextAreaElement,HTMLInputElement,HTMLScriptElement];
 
+    // Valid properties
+    var validProperty = ['width', 'height', 'align', 'border', 'src', 'tabindex'];
+
     // Valid CSS attributes
     var validStyle = ['color', 'font-weight', 'font-size', 'background', 'background-color', 'margin'];
 
@@ -750,7 +757,7 @@ jSuites.editor = (function(el, options) {
            }
            // Process image
            if (element.tagName.toUpperCase() == 'IMG') {
-               if (! obj.options.acceptImages) {
+               if (! obj.options.acceptImages || ! element.src) {
                    element.parentNode.removeChild(element);
                } else {
                    // Check if is data
@@ -758,12 +765,19 @@ jSuites.editor = (function(el, options) {
                    // Check attributes for persistance
                    obj.addImage(element.src);
                }
-           } else {
-               // Remove attributes
-               var numAttributes = element.attributes.length - 1;
+           }
+           // Remove attributes
+           var attr = [];
+           var numAttributes = element.attributes.length - 1;
+           if (numAttributes > 0) {
                for (var i = numAttributes; i >= 0 ; i--) {
-                   element.removeAttribute(element.attributes[i].name);
+                   attr.push(element.attributes[i].name);
                }
+               attr.forEach(function(v) {
+                   if (validProperty.indexOf(v) == -1) {
+                       element.removeAttribute(v);
+                   }
+               });
            }
            element.style = '';
            // Add valid style

programming_language: JavaScript