discourse/lib/onebox
Alan Guo Xiang Tan c8da2a33e8
FIX: Attempt to onebox even if response body exceeds max_download_kb (#26929)
In 95a82d608d, we lowered the default for
`Onebox.options.max_download_kb` from 10mb to 2mb for security hardening
purposes. However, this resulted in multiple bug reports where seemingly
nomral URLs stopped being oneboxed. It turns out that lowering
`Onebox.options.max_download_kb` resulted in `Onebox::Helpers::DownloadTooLarge` being raised
more often for more URLs  in `Onebox::Helpers.fetch_response` which
`Onebox::Helpers.fetch_html_doc` relies on. When
`Onebox::Helpers::DownloadTooLarge` is raised in
`Onebox::Helpers.fetch_response`, we throw away whatever response body
which we have already downloaded at that point. This is not ideal
because Nokogiri can parse incomplete HTML documents and there is a
really high chance that the incomplete HTML document still contains the
information which we need for oneboxing.

Therefore, this commit updates `Onebox::Helpers.fetch_html_doc` to not
throw away the response body when the size of the response body exceeds
`Onebox.options.max_download_size`. Instead, we just take whatever
response which we have and get Nokogiri to parse it.
2024-05-09 07:00:34 +08:00
..
engine FEATURE: Add onebox for loom (#26016) 2024-03-04 15:12:08 -07:00
mixins FIX: Localize text in github oneboxes (#25327) 2024-01-19 11:26:06 -03:00
templates FIX: Allow sanitized-HTML in GH issues and categories oneboxes. (#25374) 2024-01-22 15:25:29 -03:00
domain_checker.rb DEV: Fix various rubocop lints (#24749) 2023-12-06 23:25:00 +01:00
engine.rb FEATURE: Add onebox for loom (#26016) 2024-03-04 15:12:08 -07:00
file_type_finder.rb DEV: Apply syntax_tree formatting to lib/* 2023-01-09 12:10:19 +00:00
helpers.rb FIX: Attempt to onebox even if response body exceeds max_download_kb (#26929) 2024-05-09 07:00:34 +08:00
json_ld.rb DEV: Replace custom Onebox blank implementation with ActiveSupport (#23827) 2023-10-07 19:54:26 +02:00
layout_support.rb DEV: Apply syntax_tree formatting to lib/* 2023-01-09 12:10:19 +00:00
layout.rb DEV: Replace custom Onebox symbolize_keys implementation with ActiveSupport (#23828) 2023-10-09 09:32:09 +02:00
matcher.rb DEV: Apply syntax_tree formatting to lib/* 2023-01-09 12:10:19 +00:00
movie.rb DEV: Apply syntax_tree formatting to lib/* 2023-01-09 12:10:19 +00:00
normalizer.rb DEV: Replace custom Onebox blank implementation with ActiveSupport (#23827) 2023-10-07 19:54:26 +02:00
oembed.rb DEV: Replace custom Onebox symbolize_keys implementation with ActiveSupport (#23828) 2023-10-09 09:32:09 +02:00
open_graph.rb DEV: Replace custom Onebox blank implementation with ActiveSupport (#23827) 2023-10-07 19:54:26 +02:00
preview.rb DEV: Apply syntax_tree formatting to lib/* 2023-01-09 12:10:19 +00:00
sanitize_config.rb DEV: Prefer \A and \z over ^ and $ in regexes (#19936) 2023-01-20 12:52:49 -06:00
status_check.rb SECURITY: Expand and improve SSRF Protections (#18815) 2022-11-01 16:33:17 +00:00
template_support.rb
view.rb