mirror of
https://github.com/ether/etherpad-lite.git
synced 2025-04-21 07:56:16 -04:00
Add support for square brackets in URLs
This reverts commit 9022877cc6
.
This commit is contained in:
parent
09f8ffbdb6
commit
336d48add7
2 changed files with 4 additions and 21 deletions
|
@ -60,10 +60,10 @@ const wordCharRegex = new RegExp(`[${[
|
|||
const urlRegex = (() => {
|
||||
// TODO: wordCharRegex matches many characters that are not permitted in URIs. Are they included
|
||||
// here as an attempt to support IRIs? (See https://tools.ietf.org/html/rfc3987.)
|
||||
const urlChar = `[-:@_.,~%+/?=&#!;()$'*${wordCharRegex.source.slice(1, -1)}]`;
|
||||
const urlChar = `[-:@_.,~%+/?=&#!;()\\[\\]$'*${wordCharRegex.source.slice(1, -1)}]`;
|
||||
// Matches a single character that should not be considered part of the URL if it is the last
|
||||
// character that matches urlChar.
|
||||
const postUrlPunct = '[:.,;?!)\'*]';
|
||||
const postUrlPunct = '[:.,;?!)\\]\'*]';
|
||||
// Schemes that must be followed by ://
|
||||
const withAuth = `(?:${[
|
||||
'(?:x-)?man',
|
||||
|
|
|
@ -28,7 +28,7 @@ describe('urls', function () {
|
|||
});
|
||||
|
||||
describe('special characters inside URL', function () {
|
||||
for (const char of '-:@_.,~%+/?=&#!;()$\'*') {
|
||||
for (const char of '-:@_.,~%+/?=&#!;()[]$\'*') {
|
||||
const url = `https://etherpad.org/${char}foo`;
|
||||
it(url, async function () {
|
||||
await helper.edit(url);
|
||||
|
@ -41,7 +41,7 @@ describe('urls', function () {
|
|||
});
|
||||
|
||||
describe('punctuation after URL is ignored', function () {
|
||||
for (const char of ':.,;?!)\'*]') {
|
||||
for (const char of ':.,;?!)]\'*') {
|
||||
const want = 'https://etherpad.org';
|
||||
const input = want + char;
|
||||
it(input, async function () {
|
||||
|
@ -53,21 +53,4 @@ describe('urls', function () {
|
|||
});
|
||||
}
|
||||
});
|
||||
|
||||
// Square brackets are in the RFC3986 reserved set so they can legally appear in URIs, but they
|
||||
// are explicitly excluded from linkification because including them is usually not desired (e.g.,
|
||||
// it can interfere with wiki/markdown link syntax).
|
||||
describe('square brackets are excluded from linkified URLs', function () {
|
||||
for (const char of '[]') {
|
||||
const want = 'https://etherpad.org/';
|
||||
const input = `${want}${char}foo`;
|
||||
it(input, async function () {
|
||||
await helper.edit(input);
|
||||
await helper.waitForPromise(() => txt().find('a').length === 1);
|
||||
const link = txt().find('a');
|
||||
expect(link.attr('href')).to.be(want);
|
||||
expect(link.text()).to.be(want);
|
||||
});
|
||||
}
|
||||
});
|
||||
});
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue