Skip to content

Commit

Permalink
Put sync detail detection mediastore behind feature flag (forem#21231)
Browse files Browse the repository at this point in the history
* Put sync detail detection mediastore behind feature flag

* Content safe traversal
  • Loading branch information
benhalpern authored Aug 26, 2024
1 parent 5d7c614 commit 84aef58
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions app/lib/redcarpet/render/html_rouge.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@ def image(link, title, alt_text)
end
end

def link(link, _title, content)
def link(link, _title, content) # rubocop:disable Metrics/PerceivedComplexity
# Regex to capture src, alt, and title attributes from an img tag
if content.include?("<img") && (doc = Nokogiri::HTML(content))
if content&.include?("<img") && (doc = Nokogiri::HTML(content))
image_url = doc.at_css("img")["src"]
alt_text = doc.at_css("img")["alt"] || nil
title = doc.at_css("img")["title"] || nil
Expand Down
2 changes: 1 addition & 1 deletion app/services/content_renderer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ def initialize(input, source: nil, user: nil, fixer: MarkdownProcessor::Fixer::F
# @return [ContentRenderer::Result]
def process(link_attributes: {},
prefix_images_options: { width: 800, synchronous_detail_detection: false })
if prefix_images_options[:synchronous_detail_detection] && ApplicationConfig["AWS_BUCKET_NAME"].present?
if prefix_images_options[:synchronous_detail_detection] && ApplicationConfig["AWS_BUCKET_NAME"].present? && FeatureFlag.enabled?(:store_images) # rubocop:disable Layout/LineLength
markdown_text = input
markdown_pattern = /!\[.*?\]\((.*?)\)/
html_pattern = /<img.*?src=["'](.*?)["']/
Expand Down

0 comments on commit 84aef58

Please sign in to comment.