mirror of
https://github.com/discourse/discourse.git
synced 2025-05-25 00:32:52 +08:00
FIX: Force string conversions to UTF-8 "bytes" (#11315)
https://meta.discourse.org/t/cant-create-poll-with-some-chinese-options/170836
This commit is contained in:
@ -403,10 +403,9 @@ function ii(a, b, c, d, x, s, t) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function md51(s) {
|
function md51(s) {
|
||||||
// Converts the string to UTF-8 "bytes" when necessary
|
// Converts the string to UTF-8 "bytes"
|
||||||
if (/[\x80-\xFF]/.test(s)) {
|
s = unescape(encodeURI(s));
|
||||||
s = unescape(encodeURI(s));
|
|
||||||
}
|
|
||||||
var n = s.length,
|
var n = s.length,
|
||||||
state = [1732584193, -271733879, -1732584194, 271733878],
|
state = [1732584193, -271733879, -1732584194, 271733878],
|
||||||
i;
|
i;
|
||||||
|
@ -71,6 +71,16 @@ describe PostsController do
|
|||||||
expect(json["errors"][0]).to eq(I18n.t("poll.default_poll_must_have_different_options"))
|
expect(json["errors"][0]).to eq(I18n.t("poll.default_poll_must_have_different_options"))
|
||||||
end
|
end
|
||||||
|
|
||||||
|
it "accepts different Chinese options" do
|
||||||
|
SiteSetting.default_locale = 'zh_CN'
|
||||||
|
|
||||||
|
post :create, params: {
|
||||||
|
title: title, raw: "[poll]\n- Microsoft Edge(新)\n- Microsoft Edge(旧)\n[/poll]"
|
||||||
|
}, format: :json
|
||||||
|
|
||||||
|
expect(response).to be_successful
|
||||||
|
end
|
||||||
|
|
||||||
it "should have at least 1 options" do
|
it "should have at least 1 options" do
|
||||||
post :create, params: {
|
post :create, params: {
|
||||||
title: title, raw: "[poll]\n[/poll]"
|
title: title, raw: "[poll]\n[/poll]"
|
||||||
|
Reference in New Issue
Block a user