escape customer, project and activity name in javascript (#2959)

This commit is contained in:
Kevin Papst
2021-11-19 19:45:37 +01:00
committed by GitHub
parent 859131308a
commit 89bfa82c61
7 changed files with 23 additions and 7 deletions

View File

@@ -66,4 +66,19 @@ export default class KimaiPlugin {
return this.getContainer().getPlugin(name);
}
/**
* @param {string} title
* @returns {string}
*/
escape(title) {
const tagsToReplace = {
'&': '&',
'<': '&lt;',
'>': '&gt;',
};
return title.replace(/[&<>]/g, function(tag) {
return tagsToReplace[tag] || tag;
});
};
}

View File

@@ -65,9 +65,10 @@ export default class KimaiRecentActivities extends KimaiPlugin {
for (let timesheet of entries) {
let label = this.attributes['template']
.replace('%customer%', timesheet.project.customer.name)
.replace('%project%', timesheet.project.name)
.replace('%activity%', timesheet.activity.name);
.replace('%customer%', this.escape(timesheet.project.customer.name))
.replace('%project%', this.escape(timesheet.project.name))
.replace('%activity%', this.escape(timesheet.activity.name))
;
htmlToInsert +=
`<li>` +

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@@ -3,7 +3,7 @@
"app": {
"js": [
"build/runtime.b8e7bb04.js",
"build/app.3947eaef.js"
"build/app.9e8f68cf.js"
],
"css": [
"build/app.3bc2b4d9.css"

View File

@@ -1,6 +1,6 @@
{
"build/app.css": "build/app.3bc2b4d9.css",
"build/app.js": "build/app.3947eaef.js",
"build/app.js": "build/app.9e8f68cf.js",
"build/invoice.css": "build/invoice.ff32661a.css",
"build/invoice.js": "build/invoice.19f36eca.js",
"build/invoice-pdf.css": "build/invoice-pdf.9a7468ef.css",