Skip to content

Commit 298ed7e

Browse files
committed
Merge remote-tracking branch 'origin/stable' into pkgr
2 parents 5690d25 + b9bc27e commit 298ed7e

23 files changed

+39
-14
lines changed

app/controllers/admin/backups_controller.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ def show
7070
send_file backup.path
7171
else
7272
if @error
73-
render layout: 'no_ember', status: 422
73+
render template: 'admin/backups/show.html.erb', layout: 'no_ember', status: 422
7474
else
7575
render body: nil, status: 404
7676
end

app/controllers/users_controller.rb

+2-2
Original file line numberDiff line numberDiff line change
@@ -504,8 +504,8 @@ def password_reset
504504
success: false,
505505
message: @error,
506506
errors: @user&.errors&.to_hash,
507-
is_developer: UsernameCheckerService.is_developer?(@user.email),
508-
admin: @user.admin?
507+
is_developer: UsernameCheckerService.is_developer?(@user&.email),
508+
admin: @user&.admin?
509509
}
510510
else
511511
render json: {

app/models/topic.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -1273,7 +1273,7 @@ def pm_with_non_human_user?
12731273
end
12741274

12751275
def featured_link_root_domain
1276-
MiniSuffix.domain(URI.parse(self.featured_link).hostname)
1276+
MiniSuffix.domain(URI.parse(URI.encode(self.featured_link)).hostname)
12771277
end
12781278

12791279
private

app/models/topic_embed.rb

+2-2
Original file line numberDiff line numberDiff line change
@@ -182,8 +182,8 @@ def self.absolutize_urls(url, contents)
182182
end
183183

184184
def self.topic_id_for_embed(embed_url)
185-
embed_url = normalize_url(embed_url)
186-
TopicEmbed.where("lower(embed_url) = ?", embed_url).pluck(:topic_id).first
185+
embed_url = normalize_url(embed_url).sub(/^https?\:\/\//, '')
186+
TopicEmbed.where("embed_url ~* '^https?://#{embed_url}$'").pluck(:topic_id).first
187187
end
188188

189189
def self.first_paragraph_from(html)

lib/cooked_post_processor.rb

+2-1
Original file line numberDiff line numberDiff line change
@@ -237,7 +237,8 @@ def get_size(url)
237237
return unless SiteSetting.crawl_images? || Discourse.store.has_been_uploaded?(url)
238238

239239
@size_cache[url] = FastImage.size(absolute_url)
240-
rescue Zlib::BufError # FastImage.size raises BufError for some gifs
240+
rescue Zlib::BufError, URI::InvalidURIError, URI::InvalidComponentError
241+
# FastImage.size raises BufError for some gifs, leave it.
241242
end
242243

243244
def is_valid_image_url?(url)

lib/emoji/db.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -5754,7 +5754,7 @@
57545754
},
57555755
{
57565756
"code": "1f92b",
5757-
"name": "sushing_face"
5757+
"name": "shushing_face"
57585758
},
57595759
{
57605760
"code": "1f92d",

lib/emoji/groups.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -325,7 +325,7 @@
325325
"diversity": false
326326
},
327327
{
328-
"name": "sushing_face",
328+
"name": "shushing_face",
329329
"diversity": false
330330
},
331331
{

lib/version.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ module Discourse
44
module VERSION #:nodoc:
55
MAJOR = 1
66
MINOR = 9
7-
TINY = 0
7+
TINY = 1
88
PRE = nil
99

1010
STRING = [MAJOR, MINOR, TINY, PRE].compact.join('.')
5.35 KB
Loading
Loading
1.15 KB
Loading
-1.07 KB
Binary file not shown.
Binary file not shown.
-1.15 KB
Binary file not shown.
889 Bytes
Loading
-1.15 KB
Binary file not shown.

spec/controllers/users_controller_spec.rb

+11-3
Original file line numberDiff line numberDiff line change
@@ -303,11 +303,9 @@
303303
context 'invalid token' do
304304
render_views
305305

306-
before do
306+
it 'disallows login' do
307307
get :password_reset, params: { token: "evil_trout!" }
308-
end
309308

310-
it 'disallows login' do
311309
expect(response).to be_success
312310

313311
expect(CGI.unescapeHTML(response.body))
@@ -319,6 +317,16 @@
319317

320318
expect(session[:current_user_id]).to be_blank
321319
end
320+
321+
it "responds with proper error message" do
322+
put :password_reset, params: {
323+
token: "evil_trout!", password: "awesomeSecretPassword"
324+
}, format: :json
325+
326+
expect(response).to be_success
327+
expect(JSON.parse(response.body)["message"]).to eq(I18n.t('password_reset.no_token'))
328+
expect(session[:current_user_id]).to be_blank
329+
end
322330
end
323331

324332
context 'valid token' do

spec/models/topic_embed_spec.rb

+14
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,20 @@
6060

6161
end
6262

63+
context '.topic_id_for_embed' do
64+
it "returns correct topic id irrespective of url protocol" do
65+
topic_embed = Fabricate(:topic_embed, embed_url: "http://example.com/post/248")
66+
67+
expect(TopicEmbed.topic_id_for_embed('http://exAMPle.com/post/248')).to eq(topic_embed.topic_id)
68+
expect(TopicEmbed.topic_id_for_embed('https://example.com/post/248/')).to eq(topic_embed.topic_id)
69+
70+
expect(TopicEmbed.topic_id_for_embed('http://example.com/post/248/2')).to eq(nil)
71+
expect(TopicEmbed.topic_id_for_embed('http://examples.com/post/248')).to eq(nil)
72+
expect(TopicEmbed.topic_id_for_embed('http://example.com/post/24')).to eq(nil)
73+
expect(TopicEmbed.topic_id_for_embed('http://example.com/post')).to eq(nil)
74+
end
75+
end
76+
6377
describe '.find_remote' do
6478

6579
context ".title_scrub" do

spec/models/topic_spec.rb

+1
Original file line numberDiff line numberDiff line change
@@ -2101,6 +2101,7 @@ def build_topic_with_title(title)
21012101
"https://meta.discourse.org",
21022102
"https://meta.discourse.org/",
21032103
"https://meta.discourse.org/?filter=test",
2104+
"https://meta.discourse.org/t/中國/1",
21042105
].each do |featured_link|
21052106
it "should extract the root domain from #{featured_link} correctly" do
21062107
topic.featured_link = featured_link

spec/requests/embed_controller_spec.rb

+2-1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
let(:host) { "eviltrout.com" }
66
let(:embed_url) { "http://eviltrout.com/2013/02/10/why-discourse-uses-emberjs.html" }
7+
let(:embed_url_secure) { "https://eviltrout.com/2013/02/10/why-discourse-uses-emberjs.html" }
78
let(:discourse_username) { "eviltrout" }
89

910
it "is 404 without an embed_url" do
@@ -95,7 +96,7 @@
9596
it "displays the right view" do
9697
topic_embed = Fabricate(:topic_embed, embed_url: embed_url)
9798

98-
get '/embed/comments', params: { embed_url: embed_url }, headers: headers
99+
get '/embed/comments', params: { embed_url: embed_url_secure }, headers: headers
99100

100101
expect(response.body).to match(I18n.t('embed.start_discussion'))
101102
end

0 commit comments

Comments
 (0)