1
0
Fork 0
mirror of https://gitlab.com/bramw/baserow.git synced 2025-04-15 09:34:13 +00:00

AB Fix Link elements using Custom URL with protocols like mailto

This commit is contained in:
Tsering Paljor 2024-05-30 08:38:13 +00:00 committed by Jérémie Pardou
parent 5308fd23a8
commit 9ea3225594
4 changed files with 43 additions and 4 deletions

View file

@ -0,0 +1,7 @@
{
"type": "breaking_change",
"message": "In the Application Builder, when using a Custom URL in a Link element the Destination URL is no longer automatically prefixed with https://. Additionally, only these protocols are allowed in the Destination URL: ftp, ftps, ftpes, http, https, mailto, sftp, sms, and tel.",
"issue_number": 2642,
"bullet_points": [],
"created_at": "2024-05-30"
}

View file

@ -0,0 +1,7 @@
{
"type": "bug",
"message": "Ensure Link elements work with Custom URL protocols like mailto, sms, or tel.",
"issue_number": 2642,
"bullet_points": [],
"created_at": "2024-05-28"
}

View file

@ -22,6 +22,18 @@ export const PAGE_PARAM_TYPE_VALIDATION_FUNCTIONS = {
text: ensureNonEmptyString,
}
export const ALLOWED_LINK_PROTOCOLS = [
'ftp:',
'ftps:',
'ftpes:',
'http:',
'https:',
'mailto:',
'sftp:',
'sms:',
'tel:',
]
export const TEXT_FORMAT_TYPES = {
PLAIN: 'plain',
MARKDOWN: 'markdown',

View file

@ -1,5 +1,8 @@
import { compile } from 'path-to-regexp'
import { PAGE_PARAM_TYPE_VALIDATION_FUNCTIONS } from '@baserow/modules/builder/enums'
import {
ALLOWED_LINK_PROTOCOLS,
PAGE_PARAM_TYPE_VALIDATION_FUNCTIONS,
} from '@baserow/modules/builder/enums'
import { ensureString } from '@baserow/modules/core/utils/validator'
/**
@ -56,10 +59,20 @@ export default function resolveElementUrl(
element.navigation_type,
editorMode
)
const protocolRegex = /^[a-zA-Z]+:\/\//
if (!resolvedUrl.startsWith('/') && !protocolRegex.test(resolvedUrl)) {
resolvedUrl = `https://${resolvedUrl}`
// If the protocol is a supported one, return early.
const protocolRegex = /^[A-Za-z]+:/
if (protocolRegex.test(resolvedUrl)) {
for (const protocol of ALLOWED_LINK_PROTOCOLS) {
if (resolvedUrl.toLowerCase().startsWith(protocol)) {
return resolvedUrl
}
}
// Disallow unsupported protocols, e.g. `javascript:`
return ''
}
return resolvedUrl
}