mirror of
https://github.com/gchq/CyberChef.git
synced 2025-04-20 14:56:19 -04:00
switched from jquery.cpath.js to xpath.js
This commit is contained in:
parent
dea16f63f5
commit
8db1b2fc79
3 changed files with 2820 additions and 726 deletions
|
@ -130,7 +130,7 @@ module.exports = function(grunt) {
|
||||||
"src/js/lib/vkbeautify.js",
|
"src/js/lib/vkbeautify.js",
|
||||||
"src/js/lib/Sortable.js",
|
"src/js/lib/Sortable.js",
|
||||||
"src/js/lib/bootstrap-colorpicker.js",
|
"src/js/lib/bootstrap-colorpicker.js",
|
||||||
"src/js/lib/jquery.xpath.js",
|
"src/js/lib/xpath.js",
|
||||||
|
|
||||||
// Custom libraries
|
// Custom libraries
|
||||||
"src/js/lib/canvas_components.js",
|
"src/js/lib/canvas_components.js",
|
||||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -1,3 +1,5 @@
|
||||||
|
/* globals xpath */
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Identifier extraction operations.
|
* Identifier extraction operations.
|
||||||
*
|
*
|
||||||
|
@ -309,6 +311,8 @@ var Extract = {
|
||||||
/**
|
/**
|
||||||
* Extract information (from an xml document) with an XPath query
|
* Extract information (from an xml document) with an XPath query
|
||||||
*
|
*
|
||||||
|
* @author Mikescher (https://github.com/Mikescher | https://mikescher.com)
|
||||||
|
*
|
||||||
* @param {string} input
|
* @param {string} input
|
||||||
* @param {Object[]} args
|
* @param {Object[]} args
|
||||||
* @returns {string}
|
* @returns {string}
|
||||||
|
@ -326,7 +330,7 @@ var Extract = {
|
||||||
|
|
||||||
var result;
|
var result;
|
||||||
try {
|
try {
|
||||||
result = $.xpath(xml, query);
|
result = xpath.evaluate(xml, query);
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
return "Invalid XPath. Details:\n" + err.message;
|
return "Invalid XPath. Details:\n" + err.message;
|
||||||
}
|
}
|
||||||
|
@ -362,6 +366,8 @@ var Extract = {
|
||||||
/**
|
/**
|
||||||
* Extract information (from an hmtl document) with an css selector
|
* Extract information (from an hmtl document) with an css selector
|
||||||
*
|
*
|
||||||
|
* @author Mikescher (https://github.com/Mikescher | https://mikescher.com)
|
||||||
|
*
|
||||||
* @param {string} input
|
* @param {string} input
|
||||||
* @param {Object[]} args
|
* @param {Object[]} args
|
||||||
* @returns {string}
|
* @returns {string}
|
||||||
|
@ -376,7 +382,7 @@ var Extract = {
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
return "Invalid input HTML.";
|
return "Invalid input HTML.";
|
||||||
}
|
}
|
||||||
|
|
||||||
var result;
|
var result;
|
||||||
try {
|
try {
|
||||||
result = $(html).find(query);
|
result = $(html).find(query);
|
||||||
|
@ -388,7 +394,7 @@ var Extract = {
|
||||||
switch (node.nodeType) {
|
switch (node.nodeType) {
|
||||||
case Node.ELEMENT_NODE: return node.outerHTML;
|
case Node.ELEMENT_NODE: return node.outerHTML;
|
||||||
case Node.ATTRIBUTE_NODE: return node.value;
|
case Node.ATTRIBUTE_NODE: return node.value;
|
||||||
case Node.COMMENT_NODE: return node.ata;
|
case Node.COMMENT_NODE: return node.data;
|
||||||
case Node.TEXT_NODE: return node.wholeText;
|
case Node.TEXT_NODE: return node.wholeText;
|
||||||
case Node.DOCUMENT_NODE: return node.outerHTML;
|
case Node.DOCUMENT_NODE: return node.outerHTML;
|
||||||
default: throw new Error("Unknown Node Type: " + node.nodeType);
|
default: throw new Error("Unknown Node Type: " + node.nodeType);
|
||||||
|
@ -396,7 +402,9 @@ var Extract = {
|
||||||
};
|
};
|
||||||
|
|
||||||
return Array.apply(null, Array(result.length))
|
return Array.apply(null, Array(result.length))
|
||||||
.map((_, i) => result[i])
|
.map(function(_, i) {
|
||||||
|
return result[i];
|
||||||
|
})
|
||||||
.map(nodeToString)
|
.map(nodeToString)
|
||||||
.join(delimiter);
|
.join(delimiter);
|
||||||
},
|
},
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue