Skip to content

Commit

Permalink
Merge pull request #206 from speee/prevent-escape-korean-emoji
Browse files Browse the repository at this point in the history
Prevent over-escaping in Korean emoji shorthand
  • Loading branch information
Yuki Hattori authored Oct 20, 2020
2 parents 9cfb368 + 4d86874 commit e105a79
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 3 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@

- [Configurable `dispatchAction` prop](https://github.com/speee/jsx-slack/blob/master/docs/block-elements.md#input) for `<Input type="text">` and `<Textarea>` (equivalent to [`dispatch_action_config` for the plain-text input](https://api.slack.com/reference/block-kit/block-elements#input)) ([#204](https://github.com/speee/jsx-slack/issues/204), [#205](https://github.com/speee/jsx-slack/pull/205))

### Fixed

- Escaped underscores within Korean emoji shorthand have broken ([#203](https://github.com/speee/jsx-slack/issues/203), [#206](https://github.com/speee/jsx-slack/pull/206))

## v2.5.1 - 2020-10-08

### Added
Expand Down
2 changes: 1 addition & 1 deletion src/mrkdwn/escape.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// An internal HTML tag and emoji shorthand should not escape
const preventEscapeRegex = /(<.*?>|:[-a-z0-9ÀÁÂÃÄÇÈÉÊËÍÎÏÑÓÔÕÖŒœÙÚÛÜŸßàáâãäçèéêëíîïñóôõöùúûüÿ__+'\u2e80-\u2fd5\u3005\u3041-\u3096\u30a0-\u30ff\u3400-\u4db5\u4e00-\u9fcb\uff10-\uff19\uff41-\uff5a\uff61-\uff9f]+:)/
const preventEscapeRegex = /(<.*?>|:[-a-z0-9ÀÁÂÃÄÇÈÉÊËÍÎÏÑÓÔÕÖŒœÙÚÛÜŸßàáâãäçèéêëíîïñóôõöùúûüÿ__+'\u1100-\u11ff\u2e80-\u2fd5\u3005\u3041-\u3096\u30a0-\u30ff\u3130-\u318f\u3400-\u4db5\u4e00-\u9fcb\ua960-\ua97f\uac00-\ud7ff\uff10-\uff19\uff41-\uff5a\uff61-\uff9f]+:)/

const generateReplacerForEscape = (fallback: string) => (matched: string) =>
`<span data-escape="${fallback.repeat(matched.length)}">${matched}</span>`
Expand Down
7 changes: 5 additions & 2 deletions test/block-kit/builtin-components.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -50,15 +50,18 @@ describe('Built-in components', () => {
JSXSlack(
<Blocks>
<Section>
<Escape>_:arrow_down: :custom_emoji: :カスタム_絵文字:_</Escape>
<Escape>
_:arrow_down: :custom_emoji: :カスタム_絵文字:
:커스텀_이모티콘:_
</Escape>
</Section>
</Blocks>
)
).toStrictEqual([
expect.objectContaining({
text: expect.objectContaining({
text:
'<!date^00000000^{_}|_>:arrow_down: :custom_emoji: :カスタム_絵文字:<!date^00000000^{_}|_>',
'<!date^00000000^{_}|_>:arrow_down: :custom_emoji: :カスタム_絵文字: :커스텀_이모티콘:<!date^00000000^{_}|_>',
}),
}),
]))
Expand Down

0 comments on commit e105a79

Please sign in to comment.