addresses long domain names for blossom and nostr profiles
This commit is contained in:
+11
-4
@@ -165,8 +165,8 @@ class UrlParserTest {
|
|||||||
@Test
|
@Test
|
||||||
fun testNostrUrls() =
|
fun testNostrUrls() =
|
||||||
test(
|
test(
|
||||||
"nostr:npub1aabbcc",
|
"nostr:npub142gywvjkq0dv6nupggyn2euhx4nduwc7yz5f24ah9rpmunr2s39se3xrj0",
|
||||||
Urls(bech32s = setOf("nostr:npub1aabbcc")),
|
Urls(bech32s = setOf("nostr:npub142gywvjkq0dv6nupggyn2euhx4nduwc7yz5f24ah9rpmunr2s39se3xrj0")),
|
||||||
)
|
)
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -267,8 +267,8 @@ class UrlParserTest {
|
|||||||
@Test
|
@Test
|
||||||
fun testBech12() =
|
fun testBech12() =
|
||||||
test(
|
test(
|
||||||
"nostr:npub1aabbcc",
|
"nostr:npub142gywvjkq0dv6nupggyn2euhx4nduwc7yz5f24ah9rpmunr2s39se3xrj0",
|
||||||
Urls(bech32s = setOf("nostr:npub1aabbcc")),
|
Urls(bech32s = setOf("nostr:npub142gywvjkq0dv6nupggyn2euhx4nduwc7yz5f24ah9rpmunr2s39se3xrj0")),
|
||||||
)
|
)
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -284,4 +284,11 @@ class UrlParserTest {
|
|||||||
"10.00hr,",
|
"10.00hr,",
|
||||||
Urls(withScheme = emptySet()),
|
Urls(withScheme = emptySet()),
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun testBlossom() =
|
||||||
|
test(
|
||||||
|
"blossom:b1674191a88ec5cdd733e4240a81803105dc412d6c6708d53ab94fc248f4f553.pdf?xs=cdn.satellite.earth",
|
||||||
|
Urls(withScheme = setOf("blossom:b1674191a88ec5cdd733e4240a81803105dc412d6c6708d53ab94fc248f4f553.pdf?xs=cdn.satellite.earth")),
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|||||||
+2
-2
@@ -770,7 +770,7 @@ class DomainNameReader(
|
|||||||
/**
|
/**
|
||||||
* The maximum length of each label in the domain name.
|
* The maximum length of each label in the domain name.
|
||||||
*/
|
*/
|
||||||
private const val MAX_LABEL_LENGTH = 64
|
private const val MAX_LABEL_LENGTH = 1000
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The maximum number of labels in a single domain name.
|
* The maximum number of labels in a single domain name.
|
||||||
@@ -780,6 +780,6 @@ class DomainNameReader(
|
|||||||
/**
|
/**
|
||||||
* The maximum domain name length.
|
* The maximum domain name length.
|
||||||
*/
|
*/
|
||||||
private const val MAX_DOMAIN_LENGTH = 255
|
private const val MAX_DOMAIN_LENGTH = 1000
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+4
-2
@@ -211,7 +211,7 @@ class UrlDetector(
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* We found a ":" and is now trying to read either scheme, username/password
|
* We found a ":" and is now trying to read either scheme, username/password
|
||||||
* @param length first index of the previous part (could be beginning of the buffer, beginning of the username/password, or beginning
|
* @param startLength first index of the previous part (could be beginning of the buffer, beginning of the username/password, or beginning
|
||||||
* @return new index of where the domain starts
|
* @return new index of where the domain starts
|
||||||
*/
|
*/
|
||||||
private fun processColon(startLength: Int): Int {
|
private fun processColon(startLength: Int): Int {
|
||||||
@@ -320,7 +320,9 @@ class UrlDetector(
|
|||||||
// Add the slashes to the end of the scheme so it matches what's in the scheme list
|
// Add the slashes to the end of the scheme so it matches what's in the scheme list
|
||||||
val schemeStartIndex = findValidSchemeNoSlashesStartIndex(buffer.toString())
|
val schemeStartIndex = findValidSchemeNoSlashesStartIndex(buffer.toString())
|
||||||
if (schemeStartIndex >= 0) {
|
if (schemeStartIndex >= 0) {
|
||||||
buffer.deleteRange(0, schemeStartIndex)
|
if (schemeStartIndex > 0) {
|
||||||
|
buffer.deleteRange(0, schemeStartIndex)
|
||||||
|
}
|
||||||
currentUrlMarker.setIndex(UrlPart.SCHEME, 0)
|
currentUrlMarker.setIndex(UrlPart.SCHEME, 0)
|
||||||
reader.goBack()
|
reader.goBack()
|
||||||
return true
|
return true
|
||||||
|
|||||||
+9
-2
@@ -174,12 +174,14 @@ class UriDetectionTest {
|
|||||||
runTest(
|
runTest(
|
||||||
(
|
(
|
||||||
"This will work: 1.2.3.4.5.6.7.8.9.0.1.2.3.4.5.6.7.8.9.0.1.2.3.4.5.6.7.8.9.0.1.2.3.4.5.6.7.8.9.0.1.2.3.4.5.6.7.8.9.0.1.2.3.4.5.6.7.8.9.0.1.2.3.4.5.6.7.8.9.0.1.2.3.4.5.6.7.8.9.0.1.2.3.4.5.6.7.8.9.0.1.2.3.4.5.6.7.8.9.0.1.2.3.4.5.6.7.8.9.0.1.2.3.4.5.6.7.8.9.0.a.b.c.d.e.ly " +
|
"This will work: 1.2.3.4.5.6.7.8.9.0.1.2.3.4.5.6.7.8.9.0.1.2.3.4.5.6.7.8.9.0.1.2.3.4.5.6.7.8.9.0.1.2.3.4.5.6.7.8.9.0.1.2.3.4.5.6.7.8.9.0.1.2.3.4.5.6.7.8.9.0.1.2.3.4.5.6.7.8.9.0.1.2.3.4.5.6.7.8.9.0.1.2.3.4.5.6.7.8.9.0.1.2.3.4.5.6.7.8.9.0.1.2.3.4.5.6.7.8.9.0.a.b.c.d.e.ly " +
|
||||||
"This will not work: 1.2.3.4.5.6.7.8.9.0.1.2.3.4.5.6.7.8.9.0.1.2.3.4.5.6.7.8.9.0.1.2.3.4.5.6.7.8.9.0.1.2.3.4.5.6.7.8.9.0.1.2.3.4.5.6.7.8.9.0.1.2.3.4.5.6.7.8.9.0.1.2.3.4.5.6.7.8.9.0.1.2.3.4.5.6.7.8.9.0.1.2.3.4.5.6.7.8.9.0.1.2.3.4.5.6.7.8.9.0.1.2.3.4.5.6.7.8.9.0.a.b.c.d.e.f.ly " +
|
"This will work: 1.2.3.4.5.6.7.8.9.0.1.2.3.4.5.6.7.8.9.0.1.2.3.4.5.6.7.8.9.0.1.2.3.4.5.6.7.8.9.0.1.2.3.4.5.6.7.8.9.0.1.2.3.4.5.6.7.8.9.0.1.2.3.4.5.6.7.8.9.0.1.2.3.4.5.6.7.8.9.0.1.2.3.4.5.6.7.8.9.0.1.2.3.4.5.6.7.8.9.0.1.2.3.4.5.6.7.8.9.0.1.2.3.4.5.6.7.8.9.0.a.b.c.d.e.f.ly " +
|
||||||
"This should as well: aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa.bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb.ccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc.dddddddddddddddddddddddddddddddddddddddddddddddddddddd.bit.ly " +
|
"This should as well: aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa.bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb.ccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc.dddddddddddddddddddddddddddddddddddddddddddddddddddddd.bit.ly " +
|
||||||
"But this wont: aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa.bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb.ccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc.dddddddddddddddddddddddddddddddddddddddddddddddddddddd.bit.ly.dbl.spamhaus.org"
|
"But should as well: aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa.bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb.ccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc.dddddddddddddddddddddddddddddddddddddddddddddddddddddd.bit.ly.dbl.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aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa.bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb.ccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc.dddddddddddddddddddddddddddddddddddddddddddddddddddddd.bit.ly",
|
||||||
|
"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa.bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb.ccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc.dddddddddddddddddddddddddddddddddddddddddddddddddddddd.bit.ly.dbl.spamhaus.org",
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -727,6 +729,11 @@ class UriDetectionTest {
|
|||||||
runTest("I saw this on hxxp://test.com I think it is really cool")
|
runTest("I saw this on hxxp://test.com I think it is really cool")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun testBlossomSchema() {
|
||||||
|
runTest("blossom:b1674191a88ec5cdd733e4240a81803105dc412d6c6708d53ab94fc248f4f553.pdf?xs=cdn.satellite.earth", "blossom:b1674191a88ec5cdd733e4240a81803105dc412d6c6708d53ab94fc248f4f553.pdf?xs=cdn.satellite.earth")
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun testBasicIPv6() {
|
fun testBasicIPv6() {
|
||||||
runTest("I saw this on http://[2001:db8:1f70:0:999:de8:7648:6e8] I think it is really cool", "http://[2001:db8:1f70:0:999:de8:7648:6e8]")
|
runTest("I saw this on http://[2001:db8:1f70:0:999:de8:7648:6e8] I think it is really cool", "http://[2001:db8:1f70:0:999:de8:7648:6e8]")
|
||||||
|
|||||||
Reference in New Issue
Block a user