Fix link paste detection concatenating URLs. Fix #12393

stable/5.2.x
Thibaud Colas 2024-10-21 09:38:12 +01:00
rodzic 78845c74f0
commit 9f9d177cc8
2 zmienionych plików z 7 dodań i 0 usunięć

Wyświetl plik

@ -70,6 +70,12 @@ export const getValidLinkURL = (text, schemes) => {
}
}
// If there is whitespace, treat text as not a URL.
// Prevents scenarios like `URL.parse('https://test.t/ http://a.b/')`.
if (/\s/.test(text)) {
return false;
}
try {
const url = new URL(text);

Wyświetl plik

@ -118,6 +118,7 @@ describe.each`
${'http://test.example.co.uk'} | ${'http://test.example.co.uk'}
${'https://example.com'} | ${'https://example.com'}
${'https://xn--ls8h.la'} | ${'https://xn--ls8h.la'}
${'http://sp.a http://c.e'} | ${false}
${'ftp://example.com'} | ${'ftp://example.com'}
${'ftps://example.com'} | ${'ftps://example.com'}
${'//example.com'} | ${false}