When I put Mastodon URLs in this post, they look fine on preview but are broken once published. First I just pasted them as plain URLs, then I tried enclosing them in markdown code, neither works.

https://ohai.social/@Taweret@timeloop.cafe/114864345876664743  
https://ohai.social/@miru@social.miyaku.media/114859196162855393  

End up looking like this:

    @Taweret@timeloop.cafe/114864345876664743" rel="nofollow ugc" target="_blank">@Taweret  

    @miru@social.miyaku.media/114859196162855393" rel="nofollow ugc" target="_blank">@Miru  

EDIT: even trying to post them in code blocks here, they end up messed up.

Here’s an image of the markdown:

  • wjs018@piefed.social
    link
    fedilink
    English
    arrow-up
    2
    ·
    29 days ago

    Ok, I was able to figure out what is happening. Basically, the way that mentions work is that the software looks for things that look like @ something @ something_else (broken up so you can see it) and assume that this is a user being mentioned. That pattern is found in the mastodon links you included and it’s messing up the formatting.

    Thanks for pointing out another issue with the markdown_to_html function!

    @[email protected] I believe the issue is here in send_post, but I don’t have an easy idea for a solution. My regex skills are awful, but if we could detect that the pattern was already part of a url, maybe ignore the mention bit? Or can do the mention without messing up the formatting of the existing <a> tag?

    • Rimu@piefed.social
      link
      fedilink
      English
      arrow-up
      2
      ·
      edit-2
      28 days ago

      Something like that.

      See how in the post above, the links go to https://piefed.social/user/lookup/miru/social.miyaku.media

      We have some code that turns @rimu@piefed.social into a link to piefed.social/u/rimu via /user/lookup and that is running amok.

      The stuff in send_post is likely another similar problem - that is the function which notifies people when they are mentioned in a post, which will be broken too.

        • klu9@piefed.socialOP
          link
          fedilink
          English
          arrow-up
          1
          ·
          28 days ago

          @[email protected] & @[email protected]

          Thanks for looking into this.

          In the meantime, is there a Fediverse / non-corporate URL redirector/shortener I could use to turn the Mastodon URLs into working links?

          (I found fedv.link but that appears to include all the original URL, which would presumably result in the same problem happening.)

          • wjs018@piefed.social
            link
            fedilink
            English
            arrow-up
            2
            ·
            28 days ago

            I don’t know of any other than generic link shorteners off the top of my head (bitly, tinyurl, etc.). However, I have a fix almost done, so it should be <24 hours before this is taken care of. There are just a couple edge cases I need to write tests for.