HaikuArchives / Vision

A native Haiku IRC client that is feature filled, fast, lightweight, and stable.
Other
11 stars 15 forks source link

URLs are not detected after a link to a bridged Matrix room in channel topic #60

Closed n0toose closed 3 years ago

n0toose commented 3 years ago

We found out that any URLs past Matrix: would not work.

[09:53:02] * AlwaysLivid has changed the topic to: Open-source operating system that specifically targets personal computing. | https://haiku-os.org | Nightlies: https://download.haiku-os.org | Bugtracker: https://dev.haiku-os.org | SCM: https://git.haiku-os.org/ | Matrix: #_oftc_#haiku:matrix.org | XMPP: #haiku%irc.oftc.net@irc.jabberfr.org | Logs: https://oftc.irclog.whitequark.org/haiku

Anything past Matrix does not get marked as a URL, specifically the Logs.

Me and @humdinger joined a test channel and found out the root cause methodically, by progressively stripping the topic apart:

[10:02:15] <AlwaysLivid> I'll remove XMPP out of the way
[10:02:24] * AlwaysLivid has changed the topic to: Matrix: #_oftc_#haiku:matrix.org | Logs: https://oftc.irclog.whitequark.org/haiku
[10:02:40] <humdinger> no URLs work
[10:03:00] <AlwaysLivid> I'll progressively tear apart the Matrix URL.
[10:03:12] * AlwaysLivid has changed the topic to: #haiku:matrix.org | Logs: https://oftc.irclog.whitequark.org/haiku
[10:03:24] <humdinger> hmm... would I need to have a working client for matrix/xmpp instealled to make the urls work?
[10:03:36] <humdinger> logs URL works
[10:03:46] <humdinger> matrix URL too
[10:03:52] <AlwaysLivid> So, it started working as soon as I removed `Matrix:`?
[10:04:01] <AlwaysLivid> or #_oftc_
[10:04:04] <humdinger> or the #_oftc_#
[10:04:06] * AlwaysLivid has changed the topic to: #_oftc_#haiku:matrix.org | Logs: https://oftc.irclog.whitequark.org/haiku
[10:04:17] <humdinger> no URLs work
[10:04:26] <AlwaysLivid> Good, I'll leave just one underscore.
[10:04:31] * AlwaysLivid has changed the topic to: #_#haiku:matrix.org | Logs: https://oftc.irclog.whitequark.org/haiku
[10:04:37] <humdinger> nope
[10:04:42] * AlwaysLivid has changed the topic to: _#haiku:matrix.org | Logs: https://oftc.irclog.whitequark.org/haiku
[10:04:47] <humdinger> works

Removing the first # in #_oftc_#haiku:matrix.org makes the Logs: link work.

lonemadmax commented 3 years ago

I think this part of the code should be in a loop until a token is found or the string is exhausted: https://github.com/HaikuArchives/Vision/blob/80260e64e84e0a33d7ae0e487245a23c077767b9/src/URLCrunch.cpp#L72..L108

The current loop finds the first URL marker in the string, and # is one of them. So when there's nothing better before, #_#haiku:matrix... is chosen. The other part calculates the end, but also discards the found mark (and advances a position) if there's nothing suitable after the prefix. And one of the conditions there is that the first character must be a number, a letter or a slash. _ is neither, so it should advance and try again, but there's no loop and returns with an error. The caller then goes on with life as it's told there are no more URLs.

It should also currently fail for https://_what.example.com | Logs: https://oftc.irclog.whitequark.org/haiku, I think.