mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-10-21 19:49:54 +00:00
Escape input, fixes #3990
This commit is contained in:
2
public/v1/js/create_transaction.js
vendored
2
public/v1/js/create_transaction.js
vendored
File diff suppressed because one or more lines are too long
2
public/v1/js/edit_transaction.js
vendored
2
public/v1/js/edit_transaction.js
vendored
File diff suppressed because one or more lines are too long
@@ -135,7 +135,17 @@ export default {
|
|||||||
aSyncFunction: function (query, done) {
|
aSyncFunction: function (query, done) {
|
||||||
axios.get(this.accountAutoCompleteURI + query)
|
axios.get(this.accountAutoCompleteURI + query)
|
||||||
.then(res => {
|
.then(res => {
|
||||||
done(res.data);
|
// loop over data
|
||||||
|
let escapedData = [];
|
||||||
|
let current;
|
||||||
|
for (const key in res.data) {
|
||||||
|
if (res.data.hasOwnProperty(key) && /^0$|^[1-9]\d*$/.test(key) && key <= 4294967294) {
|
||||||
|
current = res.data[key];
|
||||||
|
current.description = this.escapeHtml(res.data[key].description)
|
||||||
|
escapedData.push(current);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
done(escapedData);
|
||||||
})
|
})
|
||||||
.catch(err => {
|
.catch(err => {
|
||||||
// any error handler
|
// any error handler
|
||||||
|
@@ -94,7 +94,17 @@ export default {
|
|||||||
aSyncFunction: function (query, done) {
|
aSyncFunction: function (query, done) {
|
||||||
axios.get(this.categoryAutoCompleteURI + query)
|
axios.get(this.categoryAutoCompleteURI + query)
|
||||||
.then(res => {
|
.then(res => {
|
||||||
done(res.data);
|
// loop over data
|
||||||
|
let escapedData = [];
|
||||||
|
let current;
|
||||||
|
for (const key in res.data) {
|
||||||
|
if (res.data.hasOwnProperty(key) && /^0$|^[1-9]\d*$/.test(key) && key <= 4294967294) {
|
||||||
|
current = res.data[key];
|
||||||
|
current.description = this.escapeHtml(res.data[key].description)
|
||||||
|
escapedData.push(current);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
done(escapedData);
|
||||||
})
|
})
|
||||||
.catch(err => {
|
.catch(err => {
|
||||||
// any error handler
|
// any error handler
|
||||||
|
@@ -83,12 +83,41 @@ export default {
|
|||||||
aSyncFunction: function (query, done) {
|
aSyncFunction: function (query, done) {
|
||||||
axios.get(this.descriptionAutoCompleteURI + query)
|
axios.get(this.descriptionAutoCompleteURI + query)
|
||||||
.then(res => {
|
.then(res => {
|
||||||
done(res.data);
|
|
||||||
|
// loop over data
|
||||||
|
let escapedData = [];
|
||||||
|
let current;
|
||||||
|
for (const key in res.data) {
|
||||||
|
if (res.data.hasOwnProperty(key) && /^0$|^[1-9]\d*$/.test(key) && key <= 4294967294) {
|
||||||
|
current = res.data[key];
|
||||||
|
current.description = this.escapeHtml(res.data[key].description)
|
||||||
|
escapedData.push(current);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
done(escapedData);
|
||||||
})
|
})
|
||||||
.catch(err => {
|
.catch(err => {
|
||||||
// any error handler
|
// any error handler
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
|
escapeHtml: function (string) {
|
||||||
|
|
||||||
|
let entityMap = {
|
||||||
|
'&': '&',
|
||||||
|
'<': '<',
|
||||||
|
'>': '>',
|
||||||
|
'"': '"',
|
||||||
|
"'": ''',
|
||||||
|
'/': '/',
|
||||||
|
'`': '`',
|
||||||
|
'=': '='
|
||||||
|
};
|
||||||
|
|
||||||
|
return String(string).replace(/[&<>"'`=\/]/g, function fromEntityMap(s) {
|
||||||
|
return entityMap[s];
|
||||||
|
});
|
||||||
|
|
||||||
|
},
|
||||||
search: function (input) {
|
search: function (input) {
|
||||||
return ['ab', 'cd'];
|
return ['ab', 'cd'];
|
||||||
},
|
},
|
||||||
|
Reference in New Issue
Block a user