mirror of
				https://github.com/firefly-iii/firefly-iii.git
				synced 2025-10-31 02:36:28 +00:00 
			
		
		
		
	Escape input, fixes #3990
This commit is contained in:
		| @@ -135,7 +135,17 @@ export default { | ||||
|         aSyncFunction: function (query, done) { | ||||
|           axios.get(this.accountAutoCompleteURI + query) | ||||
|               .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 => { | ||||
|                 // any error handler | ||||
|   | ||||
| @@ -94,7 +94,17 @@ export default { | ||||
|     aSyncFunction: function (query, done) { | ||||
|       axios.get(this.categoryAutoCompleteURI + query) | ||||
|           .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 => { | ||||
|             // any error handler | ||||
|   | ||||
| @@ -83,12 +83,41 @@ export default { | ||||
|     aSyncFunction: function (query, done) { | ||||
|       axios.get(this.descriptionAutoCompleteURI + query) | ||||
|           .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 => { | ||||
|             // any error handler | ||||
|           }) | ||||
|     }, | ||||
|     escapeHtml: function (string) { | ||||
|  | ||||
|       let entityMap = { | ||||
|         '&': '&', | ||||
|         '<': '<', | ||||
|         '>': '>', | ||||
|         '"': '"', | ||||
|         "'": ''', | ||||
|         '/': '/', | ||||
|         '`': '`', | ||||
|         '=': '=' | ||||
|       }; | ||||
|  | ||||
|       return String(string).replace(/[&<>"'`=\/]/g, function fromEntityMap(s) { | ||||
|         return entityMap[s]; | ||||
|       }); | ||||
|  | ||||
|     }, | ||||
|     search: function (input) { | ||||
|       return ['ab', 'cd']; | ||||
|     }, | ||||
|   | ||||
		Reference in New Issue
	
	Block a user