textual icon indicating copy to clipboard operation
textual copied to clipboard

url returned by href parameter in LinkClicked is decoding when it should not (Markdown Widget)

Open jspv opened this issue 1 year ago • 0 comments

Noted that authenticated links were breaking with signature failures, and tracing it down found that the link being returned is not the same as the link being clicked. example:

#!/usr/bin/python3

from textual.app import App, ComposeResult
from textual.widgets import Markdown

text = """
Here is an image of a dog created with DALL-E 3:

![Dog](https://some.site.us/tool?st=2024-12-22T18%3A07%3A22Z&se=2024-12-22T20%3A07%3A22Z)
"""

log_file = "linktest.txt"


class MyApp(App):
    def compose(self) -> ComposeResult:
        self.md = Markdown(markdown=text)
        yield self.md

    def on_markdown_link_clicked(self, message: Markdown.LinkClicked):
        with open(log_file, "w") as f:
            f.write(f"Original message={text}\n")
            f.write(f"Link received={message.href}\n")


if __name__ == "__main__":
    app = MyApp()
    app.run()

Output:

Original message=
Here is an image of a dog created with DALL-E 3:

![Dog](https://some.site.us/tool?st=2024-12-22T18%3A07%3A22Z&se=2024-12-22T20%3A07%3A22Z)

Link received=https://some.site.us/tool?st=2024-12-22T18:07:22Z&se=2024-12-22T20:07:22Z

Note the decoding. I would expect that the link received would be identical to the link in the Markdown.

jspv avatar Dec 22 '24 20:12 jspv