Skip to content

Webhook Sending Functions Seem to Use the Regular JSON Encoder Which Escapes HTML Characters Unnecessarily #1252

@zoominGiladSher

Description

@zoominGiladSher

What happened

While working on a Github action to send a release note to a Slack channel I saw that using the PostWebhook function causes the message to have weird characters in Slack due to the HTML escaping. For example, an apostrophe is converted to '.

Expected behavior

JSON marshaller only encodes the relevant characters as defined in the Slack documentation

Steps to reproduce

Send a webhook with an apostrophe in the body of the request. See that the resulting message has an HTML escaped symbol.

reproducible code

package main

import (
	"github.com/slack-go/slack"
)

func main() {
    blocks = new(slack.Blocks)
    blocks.BlockSet = append(blocks.BlockSet, slack.NewSectionBlock(slack.NewTextBlockObject("mrkdwn", "'test' What's up", false, false), nil, nil))
    _ := slack.PostWebhook("<WebhookURL>", &slack.WebhookMessage{Blocks: blocks})
}

manifest.yaml

Not sure what this is?

Versions

  • Go: go version go1.21.5 darwin/arm64
  • slack-go/slack: v0.12.3

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