Browse Source

BUGFIX #70: Updated 'CSS selector' operation to use vanilla JS instead of jQuery, also fixing root element selection issues.

n1474335 8 years ago
parent
commit
35d74980a1

File diff suppressed because it is too large
+ 0 - 0
build/prod/cyberchef.htm


File diff suppressed because it is too large
+ 0 - 0
build/prod/index.html


File diff suppressed because it is too large
+ 0 - 0
build/prod/scripts.js


+ 1 - 1
src/js/config/OperationConfig.js

@@ -1987,7 +1987,7 @@ var OperationConfig = {
     },
     "CSS selector": {
         description: "Extract information from an HTML document with a CSS selector",
-        run: Code.runCssQuery,
+        run: Code.runCSSQuery,
         inputType: "string",
         outputType: "string",
         args: [

+ 12 - 6
src/js/operations/Code.js

@@ -378,24 +378,30 @@ var Code = {
      * CSS selector operation.
      *
      * @author Mikescher (https://github.com/Mikescher | https://mikescher.com)
+     * @author n1474335 [n1474335@gmail.com]
      * @param {string} input
      * @param {Object[]} args
      * @returns {string}
      */
-    runCssQuery: function(input, args) {
+    runCSSQuery: function(input, args) {
         var query = args[0],
-            delimiter = args[1];
+            delimiter = args[1],
+            parser = new DOMParser(),
+            html,
+            result;
+
+        if (!query.length || !input.length) {
+            return "";
+        }
 
-        var html;
         try {
-            html = $.parseHTML(input);
+            html = parser.parseFromString(input, "text/html");
         } catch (err) {
             return "Invalid input HTML.";
         }
 
-        var result;
         try {
-            result = $(html).find(query);
+            result = html.querySelectorAll(query);
         } catch (err) {
             return "Invalid CSS Selector. Details:\n" + err.message;
         }

+ 3 - 3
src/static/stats.txt

@@ -1,9 +1,9 @@
 212	source files
-115054	lines
+115060	lines
 4.3M	size
 
 142	JavaScript source files
-105894	lines
+105900	lines
 3.8M	size
 
 83	third party JavaScript source files
@@ -11,7 +11,7 @@
 3.0M	size
 
 59	first party JavaScript source files
-19636	lines
+19642	lines
 740K	size
 
 3.4M	uncompressed JavaScript size

Some files were not shown because too many files changed in this diff