Replace some data-bind="click: function(){} with object functions to prevent eval()

This commit is contained in:
the-djmaze 2022-11-29 17:29:06 +01:00
parent 95808ba377
commit 0d6499702d
17 changed files with 53 additions and 16 deletions

View file

@ -51,6 +51,11 @@ export class AttachmentModel extends AbstractModel {
return attachment;
}
toggleChecked(self, event) {
event.stopPropagation();
self.checked(!self.checked());
}
friendlySize() {
return FileInfo.friendlySize(this.estimatedSize) + (this.isLinked() ? ' 🔗' : '');
}

View file

@ -151,6 +151,10 @@ export class UserSettingsFolders /*extends AbstractViewSettings*/ {
}
}
hideError() {
this.folderListError('');
}
toggleFolderKolabType(folder, event) {
let type = event.target.value;
// TODO: append '.default' ?

View file

@ -60,6 +60,10 @@ export class UserSettingsThemes /*extends AbstractViewSettings*/ {
});
}
setTheme(theme) {
ThemeStore.theme(theme.name);
}
onBuild() {
const currentTheme = ThemeStore.theme();

View file

@ -33,6 +33,10 @@ export class AdminLoginView extends AbstractViewLogin {
});
}
hideError() {
this.submitError('');
}
submitCommand(self, event) {
let form = event.target.form,
data = new FormData(form),

View file

@ -22,6 +22,10 @@ export class AccountPopupView extends AbstractViewPopup {
});
}
hideError() {
this.submitError('');
}
submitForm(form) {
if (!this.submitRequest() && form.reportValidity()) {
const data = new FormData(form);

View file

@ -93,6 +93,10 @@ export class OpenPgpGeneratePopupView extends AbstractViewPopup {
});
}
hideError() {
this.submitError('');
}
showError(e) {
console.log(e);
if (e?.message) {

View file

@ -35,6 +35,10 @@ export class PluginPopupView extends AbstractViewPopup {
});
}
hideError() {
this.saveError('');
}
saveCommand() {
const oConfig = {
Id: this.id(),

View file

@ -88,6 +88,14 @@ export class LoginUserView extends AbstractViewLogin {
});
}
hideError() {
this.submitError('');
}
toggleSignMe() {
this.signMe(!this.signMe());
}
submitCommand(self, event) {
const email = this.email().trim();
this.email(email);

View file

@ -225,6 +225,10 @@ export class MailMessageView extends AbstractViewRight {
});
}
toggleFullInfo() {
this.showFullInfo(!this.showFullInfo());
}
closeMessage() {
currentMessage(null);
}
@ -393,9 +397,7 @@ export class MailMessageView extends AbstractViewRight {
// message information
registerShortcut('i', 'meta', [Scope.MessageList, Scope.MessageView], () => {
if (currentMessage()) {
this.showFullInfo(!this.showFullInfo());
}
currentMessage() && this.toggleFullInfo();
return false;
});

View file

@ -1,6 +1,6 @@
<div class="descWrapper" data-i18n="TOP_PANEL/LABEL_ADMIN_PANEL"></div>
<div class="alert" data-bind="hidden: !submitError()">
<a href="#" class="close" data-bind="click: function () { submitError('') }">×</a>
<a href="#" class="close" data-bind="click: hideError">×</a>
<span data-bind="text: submitError"></span>
</div>
<form action="#/" spellcheck="false" data-bind="submit: submitForm, css: {'errorAnimated': formError, 'submitting': submitRequest()}">

View file

@ -10,7 +10,7 @@
<form class="form-horizontal plugin-form" action="#/" spellcheck="false" onsubmit="return false;">
<div class="alert alert-info" data-bind="visible: !hasConfiguration()" data-i18n="POPUPS_PLUGIN/DESC_NOTHING_TO_CONFIGURE"></div>
<div class="alert" data-bind="visible: '' !== saveError()">
<a href="#" class="close" data-bind="click: function () { saveError('') }">×</a>
<a href="#" class="close" data-bind="click: hideError">×</a>
<span data-bind="text: saveError"></span>
</div>
<div data-bind="foreach: config, visible: hasConfiguration">

View file

@ -1,6 +1,6 @@
<div class="descWrapper" data-bind="visible: '' !== loadingDesc, text: loadingDesc"></div>
<div class="alert" data-bind="hidden: !submitError()" hidden="">
<a href="#" class="close" data-bind="click: function () { submitError('') }">×</a>
<a href="#" class="close" data-bind="click: hideError">×</a>
<span data-bind="text: submitError"></span>
<p data-bind="visible: '' !== submitErrorAdditional()">
<span data-i18n="GLOBAL/SERVER_MESSAGE"></span>:
@ -25,7 +25,7 @@
</div>
<div id="plugin-Login-BottomControlGroup"></div>
<div class="controls" style="display: flex">
<div class="e-checkbox" tabindex="0" data-bind="click: function(){signMe(!signMe())}, onSpace: function(){signMe(!signMe())}">
<div class="e-checkbox" tabindex="0" data-bind="click: toggleSignMe, onSpace: toggleSignMe">
<i role="checkbox" class="fontastic" data-bind="text: signMe() ? '☑' : '☐'"></i>
<span data-i18n="LOGIN/LABEL_SIGN_ME"></span>
</div>

View file

@ -123,7 +123,7 @@
<div class="messageItemHeader">
<div class="subjectParent">
<span class="infoParent g-ui-user-select-none fontastic" data-bind="click: function() { showFullInfo(!showFullInfo()); }"></span>
<span class="infoParent g-ui-user-select-none fontastic" data-bind="click: toggleFullInfo"></span>
<span class="flagParent g-ui-user-select-none flagOff fontastic" data-bind="text: message().isFlagged() ? '★' : '☆', css: {'flagOn': message().isFlagged(), 'flagOff': !message().isFlagged()}"></span>
<span class="subject" data-bind="text: message().subject, title: message().subject"></span>
<a href="#" class="close" data-bind="click: closeMessage" style="margin-top: -8px;">×</a>
@ -251,8 +251,7 @@
<div class="attachmentSize" data-bind="text: friendlySize()"></div>
</div>
<div class="checkboxAttachment fontastic"
data-bind="visible: download, text: checked() ? '☑' : '☐',
click: function () { checked(!checked()); return false }"></div>
data-bind="visible: download, text: checked() ? '☑' : '☐', click: toggleChecked"></div>
</li>
</ul>
<!-- /ko -->
@ -261,8 +260,7 @@
<li class="attachmentItem" data-bind="attr: { 'title': fileName }, css: {'checked': checked}">
<span class="attachmentName" data-bind="text: fileName"></span>
<i class="checkboxAttachment fontastic"
data-bind="visible: download, text: checked() ? '☑' : '☐',
click: function () { checked(!checked()); return false }"></i>
data-bind="visible: download, text: checked() ? '☑' : '☐', click: toggleChecked"></i>
</li>
</ul>
<!-- /ko -->

View file

@ -5,7 +5,7 @@
</header>
<form id="accountform" class="modal-body form-horizontal" autocomplete="off" spellcheck="false" data-bind="submit: submitForm">
<div class="alert" data-bind="visible: '' !== submitError()">
<a href="#" class="close" data-bind="click: function () { submitError('') }">×</a>
<a href="#" class="close" data-bind="click: hideError">×</a>
<span data-bind="text: submitError"></span>
<div data-bind="visible: submitErrorAdditional, text: submitErrorAdditional"></div>
</div>

View file

@ -4,7 +4,7 @@
</header>
<form id="openpgp-generate" class="modal-body form-horizontal" autocomplete="off" spellcheck="false" data-bind="submit: submitForm">
<div class="alert" data-bind="visible: '' !== submitError()">
<a href="#" class="close" data-bind="click: function () { submitError('') }">×</a>
<a href="#" class="close" data-bind="click: hideError">×</a>
<span data-bind="text: submitError"></span>
</div>
<!-- Disable stupid browser password autofill -->

View file

@ -34,7 +34,7 @@
<span data-i18n="SETTINGS_FOLDERS/TO_MANY_FOLDERS_DESC_2"></span>
</div>
<div class="alert folders-list-error" data-bind="visible: '' !== folderListError()">
<a href="#" class="close" data-bind="click: function () { folderListError(''); }">×</a>
<a href="#" class="close" data-bind="click: hideError">×</a>
<span data-bind="text: folderListError"></span>
</div>
<table class="table table-hover list-table" data-bind="i18nUpdate: folderList">

View file

@ -3,7 +3,7 @@
<span data-bind="saveTrigger: themeTrigger"></span>
</div>
<div data-bind="foreach: themesObjects">
<figure data-bind="click: function () { $root.theme(name); }, css: { 'selected': selected }">
<figure data-bind="click: $root.setTheme, css: { 'selected': selected }">
<figcaption data-bind="text: nameDisplay"></figcaption>
<img data-bind="attr: { 'src': themePreviewSrc }">
</figure>