Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 11 additions & 9 deletions apps/twofactor_backupcodes/js/settingsview.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,16 +59,16 @@
total: this._total,
used: this._used,
codes: this._codes,
download: this._getDownloadDataHref()
download: this._getDownloadData()
}));
},
_getDownloadDataHref: function () {
_getDownloadData: function () {
if (!this._codes) {
return '';
}
return 'data:text/plain,' + encodeURIComponent(_.reduce(this._codes, function (prev, code) {
return prev + code + "\r\n";
}, ''));
return _.reduce(this._codes, function (prev, code) {
return prev + code + "<br>";
}, '');
},
_load: function () {
this._loading = true;
Expand Down Expand Up @@ -113,10 +113,12 @@
});
},
_onPrintBackupCodes: function () {
var url = this._getDownloadDataHref();
window.open(url, t('twofactor_backupcodes', 'Nextcloud backup codes'));
window.print();
window.close();
var data = this._getDownloadData();
var newTab = window.open('', t('twofactor_backupcodes', 'Nextcloud backup codes'));
newTab.document.write('<h1>' + t('twofactor_backupcodes', 'Nextcloud backup codes') + '</h1>');
newTab.document.write(data);

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cc @LukasReschke for possible security implications of writing to the document directly

newTab.print();
newTab.close();
}
});

Expand Down