Skip to content

@ symbols in embedded code are incorrectly converted to Twitter links #34

@Nyoho

Description

@Nyoho

問題概要

埋め込みコード(<iframe>, <script>タグなど)内のURLに含まれる @ 記号が、Twitterユーザー名リンクに誤変換されてしまうことに気付きました。

再現手順

Mastodonの投稿の埋め込みコードを含むgfm記法の日記を書こうとします。

# subTitle

This is an embedding of a post of a Mathtodon server.

<iframe src="https://mathtod.online/@Nyoho/115394182617923497/embed" class="mastodon-embed" style="max-width: 100%; border: 0" width="400" allowfullscreen="allowfullscreen"></iframe><script src="https://mathtod.online/embed.js" async="async"></script>

期待される動作

<iframe> タグの src 属性内のURLはそのまま書かれている。

実際の動作

@Nyoho の部分が次のようにTwitterリンクに変換されてしまう。

<iframe src="https://mathtod.online/@<a class="tweet-url username" href="https://twitter.com/Nyoho" rel="nofollow">Nyoho</a>/115394182617923497/embed" class="mastodon-embed" style="max-width: 100%; border: 0" width="400" allowfullscreen="allowfullscreen"></iframe><script src="https://mathtod.online/embed.js" async="async"></script>

結果、src 属性が壊れて埋め込みが機能しなくなります。

Image

原因

現在の実装では、<pre><code> タグはTwitter @ メンション変換処理の前にstashされているみたいですが、<iframe><script> などの埋め込みコード用のHTMLタグはstashされていません。そのため、iframe内のURLも変換されていると思われます。

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions