mirror of
https://github.com/zulip/zulip-desktop.git
synced 2025-11-19 22:19:52 +00:00
Also fix various variable names to consistently indicate which strings contain HTML. Some of these changes close cross-site scripting vulnerabilities, and others are for consistency. It’s important to be meticulously consistent about escaping so that changes that would introduce vulnerabilities stand out as obviously wrong. Signed-off-by: Anders Kaseorg <anders@zulip.com>
53 lines
1.1 KiB
TypeScript
53 lines
1.1 KiB
TypeScript
import {htmlEscape} from 'escape-goat';
|
|
|
|
import * as t from '../../utils/translation-util';
|
|
|
|
import BaseSection from './base-section';
|
|
import NewServerForm from './new-server-form';
|
|
|
|
interface ServersSectionProps {
|
|
$root: Element;
|
|
}
|
|
|
|
export default class ServersSection extends BaseSection {
|
|
props: ServersSectionProps;
|
|
$newServerContainer: Element;
|
|
constructor(props: ServersSectionProps) {
|
|
super();
|
|
this.props = props;
|
|
}
|
|
|
|
templateHTML(): string {
|
|
return htmlEscape`
|
|
<div class="add-server-modal">
|
|
<div class="modal-container">
|
|
<div class="settings-pane" id="server-settings-pane">
|
|
<div class="page-title">${t.__('Add a Zulip organization')}</div>
|
|
<div id="new-server-container"></div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
`;
|
|
}
|
|
|
|
init(): void {
|
|
this.initServers();
|
|
}
|
|
|
|
initServers(): void {
|
|
this.props.$root.textContent = '';
|
|
|
|
this.props.$root.innerHTML = this.templateHTML();
|
|
this.$newServerContainer = document.querySelector('#new-server-container');
|
|
|
|
this.initNewServerForm();
|
|
}
|
|
|
|
initNewServerForm(): void {
|
|
new NewServerForm({
|
|
$root: this.$newServerContainer,
|
|
onChange: this.reloadApp
|
|
}).init();
|
|
}
|
|
}
|