mirror of
https://github.com/gchq/CyberChef.git
synced 2025-04-20 14:56:19 -04:00
BUGFIX #70: Updated 'CSS selector' operation to use vanilla JS instead of jQuery, also fixing root element selection issues.
This commit is contained in:
parent
553d9945ce
commit
35d74980a1
6 changed files with 27 additions and 21 deletions
|
@ -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;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue