chucker / Mastonaut

Simple, elegant, and native Mastodon client for Mac.
GNU General Public License v3.0
121 stars 7 forks source link

Some Links Do Not Resolve Appropriately #130

Closed dorkbuttt closed 1 year ago

dorkbuttt commented 1 year ago

https://merveilles.town/@neauoire/110452136351014091

Opening this up in Mastonaut and clicking either on the link in the Toot body or the link from the context menu, it only takes me to the front page of the Wayback Machine as opposed to the specifically linked archive. BUT, when clicking on the embedded link information that says "Shirky: Situated Software" with web.archive.org underneath it, it does take me to the intended destination.

Intended Destination: https://web.archive.org/web/20190213201804/http://shirky.com/writings/situated_software.html

Mastonaut Destination: https://web.archive.org

chucker commented 1 year ago

Thanks for filing.

  1. Link in link preview works correctly for me
  2. Link in post itself does not work correctly, but does pass through MastodonURLResolver, so the problem occurs elsewhere
  3. Link in contextual menu does not work correctly and does not pass through MastodonURLResolver at all

2 is already broken in AttributedLabel.mouseUp, so presumably, something is wrong in the parsing of posts into attributed strings in the first place.

3 is a mixture of 2 and also this code, which I should probably change to use MastodonURLResolver:

items.append(contentsOf: links.map { makeOpenURLInBrowser(title: $0.value, url: $0.key) })

Sooooo, the main bug here is 2.

chucker commented 1 year ago
(lldb) po status.attributedContent
[..]
    NSLink = "https://web.archive.org/web/20190213201804/http:/";
}
(lldb) po status.content
[..]
href=\"https://web.archive.org/web/20190213201804/http://shirky.com/writings/situated_software.html\" 
[..]

Bug seems to be in attributedStringWithSimpleHTML:removingTrailingUrl:removingInvisibleSpans.