Use raw mode on custom or broken sieve file (#3387)

* Use raw mode on custom or broken sieve file

* Fixed display of sieve filters when none are active

* Updated test
This commit is contained in:
Spitfireap
2024-12-21 15:23:32 +00:00
committed by GitHub
parent 3c5d321870
commit 2cb6ccebfa
8 changed files with 48 additions and 8 deletions
+4 -2
View File
@@ -36,8 +36,10 @@ _axios.interceptors.response.use(
return Promise.reject(error)
}
if (error.response.status !== 401 || router.currentRoute.name === 'Login') {
const busStore = useBusStore()
busStore.displayNotification({ msg: error.response.data, type: 'error' })
if (error.response.status !== 518) {
const busStore = useBusStore()
busStore.displayNotification({ msg: error.response.data, type: 'error' })
}
return Promise.reject(error)
}
const refreshToken = Cookies.get('refreshToken')
+15 -1
View File
@@ -200,6 +200,9 @@ function getFilterSetName(filterSet) {
if (filterSet.active) {
result += ' (' + $gettext('active') + ')'
}
else {
result += ' (' + $gettext('inactive') + ')'
}
return result
}
@@ -216,7 +219,12 @@ function closeFilterForm() {
function fetchFilterSets() {
accountApi.getFilterSets().then(resp => {
filterSets.value = resp.data
if (resp.data.length > 0 && resp.data[0].active && resp.data[0].name === null) {
// No filter is active
filterSets.value = resp.data.slice(1)
} else {
filterSets.value = resp.data
}
if (!currentFilterSet.value && route.params.filterset) {
for (const filterSet of filterSets.value) {
if (filterSet.name === route.params.filterset) {
@@ -233,6 +241,12 @@ function fetchFilters(filterSetName) {
accountApi.getFilters(filterSetName).then(resp => {
filters.value = resp.data
loadingFilters.value = false
}).catch(error => {
if (error.response.status === 518) { // Server is a teapot (sieve file contains custom code or is broken)
// Let the user see with rawmode
rawMode.value = true
busStore.displayNotification({ msg: $gettext('Failed to display template. Using raw mode'), type: 'warning' })
}
})
}