Skip to content

Commit

Permalink
[gui] Fix exporting checker statistics to CSV
Browse files Browse the repository at this point in the history
It is possible that a checker name contains a hashmark character
(`clang-diagnostic-#warnings`, `clang-diagnostic-#pragma-messages`).
Hashmark is a valid URL character but it starts the hash fragment and
for this reason it needs to be escaped when we export the statistics
to CSV.
  • Loading branch information
csordasmarton committed Jun 22, 2021
1 parent 97a60c2 commit 9fd5f78
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion web/server/vue-cli/src/mixins/to-csv.mixin.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,13 @@ export default {
* @param {string} fileName - default file name for export.
*/
toCSV(data, fileName) {
const content = data.map(d => d.join(",") + "\r\n").join("");
const content = data
.map(d => d.join(",") + "\r\n")
.join("")
// Hashmark (#) is a valid URL character but it starts the hash
// fragment and for this reason it needs to be escaped.
.replace("#", encodeURIComponent("#"));

const csvContent = `data:text/csv;charset=utf-8,${content}`;

const link = document.createElement("a");
Expand Down

0 comments on commit 9fd5f78

Please sign in to comment.