Xpath string results and bump marked (security)

This commit is contained in:
Gregory Schier committed 2018-01-11 12:47:25 +01:00
1 parent 09eae6a74a
commit ef2afc0bed
7 files changed
+2458 -758

No files matched your search

@@ -331,7 +331,7 @@ class CodeEditor extends React.Component {
code = `<result>${results.map(r => r.outer).join('\n')}</result>`;
} catch (err) {
// Failed to parse filter (that's ok)
code = `<result></result>`;
code = `<error>${err.message}</error>`;
}
}
+2422 -740
View File
File diff suppressed because it is too large. Load diff
+1 -1
View File
@@ -118,7 +118,7 @@
"jsonlint": "^1.6.2",
"jsonpath": "^0.2.12",
"jwt-authentication": "^0.3.3",
"marked": "^0.3.6",
"marked": "^0.3.9",
"mime-types": "^2.1.14",
"mkdirp": "^0.5.1",
"moment": "^2.18.1",
@@ -27,6 +27,13 @@ describe('query()', () => {
]
);
q('handles string query',
['<x><y>foo</y><y>bar</y></x>', 'substring(//y[1], 2)'],
[
{inner: 'oo', outer: 'oo'}
]
);
it('handles invalid query', () => {
expect(() => query('<hi>there</hi>', '//[]')).toThrowError('Invalid XPath query: //[]');
});
+20 -11
View File
@@ -18,17 +18,26 @@ module.exports.query = function (xml, query) {
}
const results = [];
for (const result of rawResults || []) {
if (result.constructor.name === 'Attr') {
results.push({
outer: result.toString().trim(),
inner: result.nodeValue
});
} else if (result.constructor.name === 'Element') {
results.push({
outer: result.toString().trim(),
inner: result.childNodes.toString()
});
// Functions return plain strings
if (typeof rawResults === 'string') {
results.push({
outer: rawResults,
inner: rawResults
});
} else {
for (const result of rawResults || []) {
if (result.constructor.name === 'Attr') {
results.push({
outer: result.toString().trim(),
inner: result.nodeValue
});
} else if (result.constructor.name === 'Element') {
results.push({
outer: result.toString().trim(),
inner: result.childNodes.toString()
});
}
}
}
+6 -4
View File
@@ -1,6 +1,8 @@
{
"requires": true,
"name": "insomnia-xpath",
"version": "0.0.5",
"lockfileVersion": 1,
"requires": true,
"dependencies": {
"xmldom": {
"version": "0.1.27",
@@ -8,9 +10,9 @@
"integrity": "sha1-1QH5ezvbQDr4757MIFcxh6rawOk="
},
"xpath": {
"version": "0.0.26",
"resolved": "https://registry.npmjs.org/xpath/-/xpath-0.0.26.tgz",
"integrity": "sha512-cn58wPnkUO7woqCLXlg9xeUMsPjMF7ZJ2gExwZ2F0IXkFAkL+6cyMdFUXJkld7Quw4k1y8QY9wlI3lMNNQkroQ=="
"version": "0.0.27",
"resolved": "https://registry.npmjs.org/xpath/-/xpath-0.0.27.tgz",
"integrity": "sha512-fg03WRxtkCV6ohClePNAECYsmpKKTv5L8y/X3Dn1hQrec3POx2jHZ/0P2qQ6HvsrU1BmeqXcof3NGGueG6LxwQ=="
}
}
}
+1 -1
View File
@@ -11,6 +11,6 @@
"dependencies": {
"insomnia-cookies": "^0.0.4",
"xmldom": "^0.1.27",
"xpath": "^0.0.26"
"xpath": "0.0.27"
}
}