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

Prevent over-escaping in Korean emoji shorthand #206

Merged
merged 4 commits into from
Oct 20, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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