diff --git a/Gemfile.lock b/Gemfile.lock
index 791aa9dc7ba..946b7245a12 100644
--- a/Gemfile.lock
+++ b/Gemfile.lock
@@ -235,7 +235,7 @@ GEM
omniauth-twitter (1.4.0)
omniauth-oauth (~> 1.1)
rack
- onebox (2.1.5)
+ onebox (2.1.6)
addressable (~> 2.7.0)
htmlentities (~> 4.3)
multi_json (~> 1.11)
diff --git a/app/assets/stylesheets/common/base/onebox.scss b/app/assets/stylesheets/common/base/onebox.scss
index 61687ebabe3..dfcb4020ba9 100644
--- a/app/assets/stylesheets/common/base/onebox.scss
+++ b/app/assets/stylesheets/common/base/onebox.scss
@@ -379,6 +379,16 @@ pre.onebox code {
white-space: normal;
}
+.onebox-warning-message {
+ margin-top: 5px;
+ color: var(--primary-med-or-secondary-med);
+ img.emoji {
+ width: 20px;
+ height: 20px;
+ float: none;
+ }
+}
+
// Onebox - Github - PR, Commit & Issue
.onebox.githubpullrequest,
.onebox.githubcommit,
diff --git a/config/locales/server.en.yml b/config/locales/server.en.yml
index b3a7e92eb50..e519c0f7b92 100644
--- a/config/locales/server.en.yml
+++ b/config/locales/server.en.yml
@@ -206,6 +206,16 @@ en:
cannot_enable_s3_uploads_when_s3_enabled_globally: "You cannot enable S3 uploads because S3 uploads are already globally enabled, and enabling this site-level could cause critical issues with uploads"
cors_origins_should_not_have_trailing_slash: "You should not add the trailing slash (/) to CORS origins."
conflicting_google_user_id: 'The Google Account ID for this account has changed; staff intervention is required for security reasons. Please contact staff and point them to
https://meta.discourse.org/t/76575'
+ onebox:
+ invalid_address: "Sorry, we were unable to generate a preview for this web page, because the server '%{hostname}' could not be found. Instead of a preview, only a link will appear in your post. :cry:"
+ error_response: "Sorry, we were unable to generate a preview for this web page, because the web server returned an error code of %{status_code}. Instead of a preview, only a link will appear in your post. :cry:"
+ missing_data:
+ one: "Sorry, we were unable to generate a preview for this web page, because the following oEmbed / OpenGraph tag could not be found: %{missing_attributes}"
+ other: "Sorry, we were unable to generate a preview for this web page, because the following oEmbed / OpenGraph tags could not be found: %{missing_attributes}"
+
+ word_connector:
+ # Connects words with a comma. Example: "foo, bar"
+ comma: ", "
activemodel:
errors:
@@ -1491,6 +1501,7 @@ en:
enable_inline_onebox_on_all_domains: "Ignore inline_onebox_domain_allowlist site setting and allow inline onebox on all domains."
force_custom_user_agent_hosts: "Hosts for which to use the custom onebox user agent on all requests. (Especially useful for hosts that limit access by user agent)."
max_oneboxes_per_post: "Maximum number of oneboxes in a post."
+ facebook_app_access_token: "A token generated from your Facebook app ID and secret. Used to generate Instagram oneboxes."
logo: "The logo image at the top left of your site. Use a wide rectangular image with a height of 120 and an aspect ratio greater than 3:1. If left blank, the site title text will be shown."
logo_small: "The small logo image at the top left of your site, seen when scrolling down. Use a square 120 × 120 image. If left blank, a home glyph will be shown."
diff --git a/config/site_settings.yml b/config/site_settings.yml
index 0b274f9ee98..08f20834a1e 100644
--- a/config/site_settings.yml
+++ b/config/site_settings.yml
@@ -1599,6 +1599,9 @@ onebox:
force_custom_user_agent_hosts:
default: "http://codepen.io"
type: list
+ facebook_app_access_token:
+ default: ""
+ secret: true
spam:
add_rel_nofollow_to_user_content: true
hide_post_sensitivity:
diff --git a/lib/final_destination.rb b/lib/final_destination.rb
index b5a4dcc4749..8bf06ee6e0f 100644
--- a/lib/final_destination.rb
+++ b/lib/final_destination.rb
@@ -67,7 +67,7 @@ class FinalDestination
@timeout = @opts[:timeout] || nil
@preserve_fragment_url = @preserve_fragment_url_hosts.any? { |host| hostname_matches?(host) }
@validate_uri = @opts.fetch(:validate_uri) { true }
- @user_agent = @force_custom_user_agent_hosts.any? { |host| hostname_matches?(host) } ? Onebox.options.user_agent : "Mozilla/5.0 (Windows NT 6.2; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.110 Safari/537.36"
+ @user_agent = @force_custom_user_agent_hosts.any? { |host| hostname_matches?(host) } ? Onebox.options.user_agent : "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/14.0 Safari/605.1.15"
end
def self.connection_timeout
@@ -170,6 +170,7 @@ class FinalDestination
end
unless validate_uri
+ @status = :invalid_address
log(:warn, "FinalDestination could not resolve URL (invalid URI): #{@uri}") if @verbose
return nil
end
@@ -276,6 +277,10 @@ class FinalDestination
(IPAddr.new(@uri.hostname) rescue nil).nil?
end
+ def hostname
+ @uri.hostname
+ end
+
def hostname_matches?(url)
url = uri(url)
@uri && url.present? && @uri.hostname == url&.hostname
diff --git a/lib/onebox/templates/discourse_user_onebox.mustache b/lib/onebox/templates/discourse_user_onebox.mustache
index 60db7491c11..88a2cddf7fa 100644
--- a/lib/onebox/templates/discourse_user_onebox.mustache
+++ b/lib/onebox/templates/discourse_user_onebox.mustache
@@ -28,5 +28,5 @@
{{/bio}}
{{joined}} {{created_at}}
-
body
@@ -210,6 +216,7 @@ describe Oneboxer do # Disable all onebox iframes: SiteSetting.allowed_onebox_iframes = "" output = Oneboxer.onebox("https://www.youtube.com/watch?v=dQw4w9WgXcQ", invalidate_oneboxes: true) + expect(output).not_to include("