mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
FIX: Further reduce the input of to_tsvector (#15716)
Random strings can result into much longer tsvectors. For example
parsing a Base64 string of ~600kb can result in a tsvector of over 1MB,
which is the maximum size of a tsvector.
Follow-up-to: 823c3f09d4
This commit is contained in:
@@ -120,11 +120,11 @@ class SearchIndexer
|
|||||||
a_weight: topic_title,
|
a_weight: topic_title,
|
||||||
b_weight: category_name,
|
b_weight: category_name,
|
||||||
c_weight: topic_tags,
|
c_weight: topic_tags,
|
||||||
# Length of a tsvector must be less than 1_048_576 bytes.
|
# The tsvector resulted from parsing a string can be double the size of
|
||||||
# The difference between the max ouptut limit and imposed input limit
|
# the original string. Since there is no way to estimate the length of
|
||||||
# accounts for the fact that sometimes the output tsvector may be
|
# the expected tsvector, we limit the input to ~50% of the maximum
|
||||||
# slighlty longer than the input.
|
# length of a tsvector (1_048_576 bytes).
|
||||||
d_weight: scrub_html_for_search(cooked)[0..1_000_000]
|
d_weight: scrub_html_for_search(cooked)[0..600_000]
|
||||||
) do |params|
|
) do |params|
|
||||||
params["private_message"] = private_message
|
params["private_message"] = private_message
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user