Permalink
Show file tree
Hide file tree
2 changes: 1 addition & 1 deletion
2
app/assets/javascripts/discourse/app/components/choose-topic.hbs
2 changes: 1 addition & 1 deletion
2
app/assets/javascripts/discourse/app/templates/modal/insert-hyperlink.hbs
2 changes: 1 addition & 1 deletion
2
app/assets/javascripts/discourse/app/templates/review-topics.hbs
2 changes: 1 addition & 1 deletion
2
plugins/chat/assets/javascripts/discourse/components/chat-channel-about-view.hbs
4 changes: 2 additions & 2 deletions
4
plugins/chat/assets/javascripts/discourse/components/chat-channel-card.hbs
2 changes: 1 addition & 1 deletion
2
plugins/chat/assets/javascripts/discourse/components/chat-channel-title.hbs
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
SECURITY: XSS on chat excerpts
Non-markdown tags weren't being escaped in chat excerpts. This could be triggered by editing a chat message containing a tag (self XSS), or by replying to a chat message with a tag (XSS). Co-authored-by: Jan Cernik <jancernik12@gmail.com>
- Loading branch information
1 parent
fd16ead
commit a373bf2
Showing
10 changed files
with
68 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,7 +1,9 @@ | ||
| import { emojiUnescape } from "discourse/lib/text"; | ||
| import { htmlSafe } from "@ember/template"; | ||
| import { htmlSafe, isHTMLSafe } from "@ember/template"; | ||
| import { registerUnbound } from "discourse-common/lib/helpers"; | ||
| import { escapeExpression } from "discourse/lib/utilities"; | ||
|
|
||
| registerUnbound("replace-emoji", (text, options) => { | ||
| text = isHTMLSafe(text) ? text.toString() : escapeExpression(text); | ||
| return htmlSafe(emojiUnescape(text, options)); | ||
| }); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
29 changes: 29 additions & 0 deletions
29
app/assets/javascripts/discourse/tests/integration/helpers/replace-emoji-test.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,29 @@ | ||
| import { module, test } from "qunit"; | ||
| import { setupRenderingTest } from "discourse/tests/helpers/component-test"; | ||
| import { render } from "@ember/test-helpers"; | ||
| import { hbs } from "ember-cli-htmlbars"; | ||
|
|
||
| module("Integration | Helper | replace-emoji", function (hooks) { | ||
| setupRenderingTest(hooks); | ||
|
|
||
| test("it replaces the emoji", async function (assert) { | ||
| await render(hbs`<span>{{replace-emoji "some text :heart:"}}</span>`); | ||
|
|
||
| assert.dom(`span`).includesText("some text"); | ||
| assert.dom(`.emoji[title="heart"]`).exists(); | ||
| }); | ||
|
|
||
| test("it escapes the text", async function (assert) { | ||
| await render( | ||
| hbs`<span>{{replace-emoji "<style>body: {background: red;}</style>"}}</span>` | ||
| ); | ||
|
|
||
| assert.dom(`span`).hasText("<style>body: {background: red;}</style>"); | ||
| }); | ||
|
|
||
| test("it renders html-safe text", async function (assert) { | ||
| await render(hbs`<span>{{replace-emoji (html-safe "safe text")}}</span>`); | ||
|
|
||
| assert.dom(`span`).hasText("safe text"); | ||
| }); | ||
| }); |
2 changes: 1 addition & 1 deletion
2
app/assets/javascripts/select-kit/addon/templates/components/topic-row.hbs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters