Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Preserve URLs in links #289

Merged
merged 2 commits into from
Feb 22, 2023
Merged

Preserve URLs in links #289

merged 2 commits into from
Feb 22, 2023

Conversation

nholden
Copy link
Contributor

@nholden nholden commented Feb 16, 2023

In #288, @mrcljx pointed out that characters in link URLs that are already escaped get escaped again. For example:

<a href="https://google.com/a?x=y%3Az">show</a>

is encoded as

<https://google.com/a?x=y%253Az|show>

This PR removes implicit encoding from link URLs. Following @yhatt's recommendation, it ensures we continue to escape characters that Slack reserves. &, <, and > are replaced by corresponding HTML entities, and we continue to use urlEncode to escape |.

closes #288

@yhatt
Copy link
Owner

yhatt commented Feb 16, 2023

Thank you for your contribution 😄

The hyperlink with date formatting still has implicit URI encoding.

<a href="https://example.com/?x=y%3Az">
  <time datetime={1234567890}>{'test: {date_short}'}</time>
</a>
<!date^1234567890^test: {date_short}^https://example.com/?x=y%253Az|test: Feb 13, 2009>

In addition, ^ also should escape in the link with date formatting. If not, a hyperlink will truncate raw ^ character and after chars.

@nholden
Copy link
Contributor Author

nholden commented Feb 17, 2023

Thanks, @yhatt! Great catch.

I took a stab at addressing that in efed184. Looks good in the Block Kit Builder, but I'm open to other approaches!

Copy link
Owner

@yhatt yhatt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good for me 😄

CI has failed due to vulnerability check of dependencies. I'll work on updation in another PR.

@yhatt yhatt added this to the jsx-slack v6 milestone Feb 19, 2023
@yhatt yhatt merged commit d9c64d2 into yhatt:main Feb 22, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

MrkdwnCompiler re-encodes URL
2 participants