CircleCI-Public / slack-orb

Create custom Slack notifications for CircleCI job statuses
https://circleci.com/developer/orbs/orb/circleci/slack
MIT License
212 stars 205 forks source link

Slack notification fails when apostrophe is used in commit message #424

Open fsintegrations opened 10 months ago

fsintegrations commented 10 months ago

Orb version:

4.12.0

What happened:

Orb crashes with error unexpected EOF while looking for matching''` when the commit message or PR title contains an apostrophe

Expected behavior:

Slack notification should works fine even with apostrophe in message content

Additional Information:

Commit message that crashed the slack notification Adding flow to allowed attributes so that it's not skipped. image

I could see this issue is already in closed state but we still face this issue if the commit message or PR title contains apostrophe (') https://github.com/CircleCI-Public/slack-orb/issues/186 https://github.com/CircleCI-Public/slack-orb/pull/198

EricRibeiro commented 8 months ago

Hey @fsintegrations 👋

Thank you for bringing this to our notice, and sorry for not getting to it sooner. Special characters have been a recurring issue with this orb, and we have tried, without much success (😅), to escape them manually using Bash.

We are trying a different approach now. We have a proof-of-concept Slack orb wholly written in Go, which means that we can leverage built-in libraries to do the special characters escaping inside the JSON templates for us.

Would you be open to trying it and seeing if it solves your issue? We are looking for some early feedback. All you have to do is replace the orb version 4.12.0 in your config with dev:4463bcaee946c1e91829fdf6b3e0d1a7b6f12210:

version: 2.1

orbs:
-  slack: circleci/slack@4.12.0
+  slack: circleci/slack@dev:4463bcaee946c1e91829fdf6b3e0d1a7b6f12210

Please remember that dev:4463bcaee946c1e91829fdf6b3e0d1a7b6f12210 is a proof-of-concept, so it doesn't have feature parity with v4.12.0. As of the time of this writing, it doesn't support sub-shells expansions inside the templates:

{
    "blocks": [
        {
            "type": "section",
            "text": {
                "type": "mrkdwn",
                "text": "$(cat /tmp/msg)"
            }
        }
    ]
}

Thanks in advance, and let us know if it works for you! 🙇

Warning dev:4463bcaee946c1e91829fdf6b3e0d1a7b6f12210 will be deleted after 90 days (January 22, 2024). Remember to roll back to a production version before the developer version gets deleted.