scala-slack-bot-core icon indicating copy to clipboard operation
scala-slack-bot-core copied to clipboard

`OutboundMessage` doesn't escape the newline in JSON

Open yllan opened this issue 10 years ago • 0 comments

https://github.com/ScalaConsultants/scala-slack-bot-core/blob/master/src/main/scala/io/scalac/slack/common/Messages.scala#L52

If the text contains newline or ", it will break the JSON format.

Example:

val response = OutboundMessage(message.channel, s"""ha","escape":"bad""")
publish(response)

Expected Payload:

{
"id": 1,
"type": "message",
"channel": "D08GG2WJF",
"text": "ha\",\"escape\":\"bad"
} 

Actual Payload:

{
"id": 1,
"type": "message",
"channel": "D08GG2WJF",
"text": "ha","escape":"bad"
} 

yllan avatar Aug 04 '15 05:08 yllan