From e26437f3343bbf3360d828fe059b42ba2bb7b242 Mon Sep 17 00:00:00 2001 From: Misaka 0x4e21 Date: Mon, 13 Aug 2018 13:35:56 +0800 Subject: [PATCH] FEATURE: Do encodeURI on share links MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Some Discourse-supported sharing platforms such as Twitter are unable to determine the end of a unicode URL. If you post a URL "https://example.org/t/测试/1" on Twitter, it will be a link of href="https://example.org/t/" If the URL contains any unicode character (usually in the slug part) , it must be urlencoded with encodeURI(url) before being passed to source.generateUrl(link, title), or it will be a malformed URL in the sharing tweet. --- app/assets/javascripts/discourse/components/share-popup.js.es6 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/assets/javascripts/discourse/components/share-popup.js.es6 b/app/assets/javascripts/discourse/components/share-popup.js.es6 index 5f899f2bae4..7980b2abe31 100644 --- a/app/assets/javascripts/discourse/components/share-popup.js.es6 +++ b/app/assets/javascripts/discourse/components/share-popup.js.es6 @@ -81,7 +81,7 @@ export default Ember.Component.extend({ if (!this.site.mobileView) { $this.css({ left: "" + x + "px" }); } - this.set("link", url); + this.set("link", encodeURI(url)); this.set("visible", true); Ember.run.scheduleOnce("afterRender", this, this._focusUrl);