Allow heading tags (h1-h6) in ContentSanitizer so news editor headings render

This commit is contained in:
2026-06-04 07:52:57 +02:00
parent 0b33a1b074
commit 15870ddb1f
191 changed files with 15453 additions and 1786 deletions

View File

@@ -23,6 +23,17 @@ function normalizeType(value, fallback = 'error') {
return fallback
}
function firstValidationError(errors) {
if (!errors || typeof errors !== 'object') return ''
for (const value of Object.values(errors)) {
if (Array.isArray(value) && value[0]) return String(value[0]).trim()
if (typeof value === 'string' && value.trim()) return value.trim()
}
return ''
}
export function mapUploadErrorNotice(error, fallback = 'Upload failed.') {
const status = Number(error?.response?.status || 0)
const payload = error?.response?.data || {}
@@ -30,6 +41,7 @@ export function mapUploadErrorNotice(error, fallback = 'Upload failed.') {
const mapped = REASON_MAP[reason]
const errorCode = String(error?.code || '').toUpperCase()
const rawMessage = typeof error?.message === 'string' ? error.message.trim() : ''
const validationMessage = firstValidationError(payload?.errors)
const timedOut = errorCode === 'ECONNABORTED' || /timeout/i.test(rawMessage)
const requestTooLarge = status === 413
@@ -41,6 +53,7 @@ export function mapUploadErrorNotice(error, fallback = 'Upload failed.') {
(requestTooLarge ? 'Server rejected this upload chunk as too large. Retrying with smaller chunks may help, or increase Nginx/PHP upload limits.' : '') ||
(timedOut ? 'Upload request timed out before the server responded. Check Nginx/PHP-FPM body handling and try again.' : '') ||
mapped?.message ||
validationMessage ||
(typeof payload?.message === 'string' && payload.message.trim()) ||
rawMessage ||
fallback