mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
FIX: Onebox fails on encoded URL.
https://meta.discourse.org/t/onebox-breaks-if-theres-chinese-text-in-url/67364
This commit is contained in:
@@ -30,8 +30,10 @@ class TopicEmbed < ActiveRecord::Base
|
||||
|
||||
# Prevents double URL encode
|
||||
# https://stackoverflow.com/a/37599235
|
||||
def self.escape_uri(uri)
|
||||
URI.encode(uri).gsub(DOUBLE_ESCAPED_EXPR, '%\1')
|
||||
def self.escape_uri(uri, pattern = URI::UNSAFE)
|
||||
encoded = URI.encode(uri, pattern)
|
||||
encoded.gsub!(DOUBLE_ESCAPED_EXPR, '%\1')
|
||||
encoded
|
||||
end
|
||||
|
||||
# Import an article from a source (RSS/Atom/Other)
|
||||
|
||||
Reference in New Issue
Block a user