From 418856a7890a183e977dac32cd765409accaf51b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9gis=20Hanol?= Date: Fri, 6 Dec 2013 11:16:13 +0100 Subject: [PATCH] make sure assets always use schemaless absolute uris --- app/jobs/regular/pull_hotlinked_images.rb | 1 - lib/cooked_post_processor.rb | 8 ++------ lib/url_helper.rb | 4 +++- 3 files changed, 5 insertions(+), 8 deletions(-) diff --git a/app/jobs/regular/pull_hotlinked_images.rb b/app/jobs/regular/pull_hotlinked_images.rb index 3ff3060acad..d3b7889d63a 100644 --- a/app/jobs/regular/pull_hotlinked_images.rb +++ b/app/jobs/regular/pull_hotlinked_images.rb @@ -74,7 +74,6 @@ module Jobs options[:bypass_bump] = true if args[:bypass_bump] == true post.revise(Discourse.system_user, raw, options) end - end def extract_images_from(html) diff --git a/lib/cooked_post_processor.rb b/lib/cooked_post_processor.rb index 7a691943936..9659a83b79f 100644 --- a/lib/cooked_post_processor.rb +++ b/lib/cooked_post_processor.rb @@ -12,6 +12,7 @@ class CookedPostProcessor @dirty = false @opts = opts @post = post + @previous_cooked = (@post.cooked || "").dup @doc = Nokogiri::HTML::fragment(post.cooked) @size_cache = {} end @@ -58,7 +59,6 @@ class CookedPostProcessor src, width, height = img["src"], img["width"], img["height"] limit_size!(img) convert_to_link!(img) - @dirty |= (src != img["src"]) || (width.to_i != img["width"].to_i) || (height.to_i != img["height"].to_i) end update_topic_image(images) @@ -130,8 +130,6 @@ class CookedPostProcessor end add_lightbox!(img, original_width, original_height, upload) - - @dirty = true end def is_a_hyperlink?(img) @@ -207,8 +205,6 @@ class CookedPostProcessor result = Oneboxer.apply(@doc) do |url, element| Oneboxer.onebox(url, args) end - - @dirty |= result.changed? end def optimize_urls @@ -251,7 +247,7 @@ class CookedPostProcessor end def dirty? - @dirty + @previous_cooked != html end def html diff --git a/lib/url_helper.rb b/lib/url_helper.rb index 8e46e00ee6e..33f1b6ed4f4 100644 --- a/lib/url_helper.rb +++ b/lib/url_helper.rb @@ -1,7 +1,9 @@ module UrlHelper def is_local(url) - Discourse.store.has_been_uploaded?(url) || url =~ /^\/assets\// + Discourse.store.has_been_uploaded?(url) || + url =~ /^\/assets\// || + url.start_with?(Discourse.asset_host || Discourse.base_url_no_prefix) end def absolute(url)