diff options
author | Miguel Jacq <mig@mig5.net> | 2019-09-16 12:10:17 +1000 |
---|---|---|
committer | Miguel Jacq <mig@mig5.net> | 2019-09-16 12:10:17 +1000 |
commit | 2524ddaf9485e484c87f2cea51414fc0d362187b (patch) | |
tree | d120ce70a6d987bc4bfcf137bd004ed58f34b40b /onionshare_gui | |
parent | 957d3e9c6d424fdfc394bef529b87f52e16f371f (diff) | |
download | onionshare-2524ddaf9485e484c87f2cea51414fc0d362187b.tar.gz onionshare-2524ddaf9485e484c87f2cea51414fc0d362187b.zip |
Make setting the Content-Security-Policy header optional so it doesn't break website mode shares
Diffstat (limited to 'onionshare_gui')
-rw-r--r-- | onionshare_gui/settings_dialog.py | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/onionshare_gui/settings_dialog.py b/onionshare_gui/settings_dialog.py index 25165688..432645e6 100644 --- a/onionshare_gui/settings_dialog.py +++ b/onionshare_gui/settings_dialog.py @@ -214,10 +214,28 @@ class SettingsDialog(QtWidgets.QDialog): self.close_after_first_download_checkbox.setText(strings._("gui_settings_close_after_first_download_option")) individual_downloads_label = QtWidgets.QLabel(strings._("gui_settings_individual_downloads_label")) + # Option to disable Content Security Policy (for website sharing) + self.csp_header_enabled_checkbox = QtWidgets.QCheckBox() + self.csp_header_enabled_checkbox.setCheckState(QtCore.Qt.Checked) + self.csp_header_enabled_checkbox.setText(strings._("gui_settings_csp_header_enabled_option")) + csp_header_label = QtWidgets.QLabel(strings._("gui_settings_whats_this").format("https://github.com/micahflee/onionshare/wiki/Content-Security-Policy")) + csp_header_label.setStyleSheet(self.common.css['settings_whats_this']) + csp_header_label.setTextInteractionFlags(QtCore.Qt.TextBrowserInteraction) + csp_header_label.setOpenExternalLinks(True) + csp_header_label.setMinimumSize(csp_header_label.sizeHint()) + csp_header_layout = QtWidgets.QHBoxLayout() + csp_header_layout.addWidget(self.csp_header_enabled_checkbox) + csp_header_layout.addWidget(csp_header_label) + csp_header_layout.addStretch() + csp_header_layout.setContentsMargins(0,0,0,0) + self.csp_header_widget = QtWidgets.QWidget() + self.csp_header_widget.setLayout(csp_header_layout) + # Sharing options layout sharing_group_layout = QtWidgets.QVBoxLayout() sharing_group_layout.addWidget(self.close_after_first_download_checkbox) sharing_group_layout.addWidget(individual_downloads_label) + sharing_group_layout.addWidget(self.csp_header_widget) sharing_group = QtWidgets.QGroupBox(strings._("gui_settings_sharing_label")) sharing_group.setLayout(sharing_group_layout) @@ -517,6 +535,12 @@ class SettingsDialog(QtWidgets.QDialog): else: self.close_after_first_download_checkbox.setCheckState(QtCore.Qt.Unchecked) + csp_header_enabled = self.old_settings.get('csp_header_enabled') + if csp_header_enabled: + self.csp_header_enabled_checkbox.setCheckState(QtCore.Qt.Checked) + else: + self.csp_header_enabled_checkbox.setCheckState(QtCore.Qt.Unchecked) + autostart_timer = self.old_settings.get('autostart_timer') if autostart_timer: self.autostart_timer_checkbox.setCheckState(QtCore.Qt.Checked) @@ -982,6 +1006,7 @@ class SettingsDialog(QtWidgets.QDialog): settings.load() # To get the last update timestamp settings.set('close_after_first_download', self.close_after_first_download_checkbox.isChecked()) + settings.set('csp_header_enabled', self.csp_header_enabled_checkbox.isChecked()) settings.set('autostart_timer', self.autostart_timer_checkbox.isChecked()) settings.set('autostop_timer', self.autostop_timer_checkbox.isChecked()) |