Skip to content

Commit

Permalink
escape customer, project and activity name in javascript (#2959)
Browse files Browse the repository at this point in the history
  • Loading branch information
kevinpapst committed Nov 19, 2021
1 parent 8591313 commit 89bfa82
Show file tree
Hide file tree
Showing 7 changed files with 23 additions and 7 deletions.
15 changes: 15 additions & 0 deletions assets/js/KimaiPlugin.js
Expand Up @@ -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;
});
};
}
7 changes: 4 additions & 3 deletions assets/js/plugins/KimaiRecentActivities.js
Expand Up @@ -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>` +
Expand Down
2 changes: 0 additions & 2 deletions public/build/app.3947eaef.js

This file was deleted.

2 changes: 2 additions & 0 deletions public/build/app.9e8f68cf.js

Large diffs are not rendered by default.

File renamed without changes.
2 changes: 1 addition & 1 deletion public/build/entrypoints.json
Expand Up @@ -3,7 +3,7 @@
"app": {
"js": [
"build/runtime.b8e7bb04.js",
"build/app.3947eaef.js"
"build/app.9e8f68cf.js"
],
"css": [
"build/app.3bc2b4d9.css"
Expand Down
2 changes: 1 addition & 1 deletion public/build/manifest.json
@@ -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",
Expand Down

0 comments on commit 89bfa82

Please sign in to comment.