Datafix: Alter style rewrite params slightly

refs RCX-1818, RCX-1971
flag=none

Test plan:
- Passes Jenkins

Change-Id: Ia8ff9873a6a06abefc016eb191ec88a96f880ae5
Reviewed-on: https://gerrit.instructure.com/c/canvas-lms/+/353336
Tested-by: Service Cloud Jenkins <svc.cloudjenkins@instructure.com>
Reviewed-by: Mysti Lilla <mysti@instructure.com>
QA-Review: Luis Oliveira <luis.oliveira@instructure.com>
Product-Review: Luis Oliveira <luis.oliveira@instructure.com>
This commit is contained in:
Matheus 2024-07-23 13:50:08 -03:00 committed by Luis Oliveira
parent 6409674b3b
commit f99fdd5a48
2 changed files with 6 additions and 4 deletions

View File

@ -49,9 +49,11 @@ module DataFixup::SetSizingForMediaAttachmentIframes
def self.fix_html(html)
doc = Nokogiri::HTML5::DocumentFragment.parse(html, nil, { max_tree_depth: 10_000 })
doc.css("iframe").select do |e|
next unless e.get_attribute("style")&.match?("width: px; height: px;")
next unless e.get_attribute("style")&.match?("width: px; height: px;") || e.get_attribute("style")&.match?("width:px; height:px;")
rewritten_style = e["style"].gsub("width: px; height: px;", "width: 320px; height: 14.25rem;")
rewritten_style = e["style"]
rewritten_style = rewritten_style.gsub("width: px; height: px;", "width: 320px; height: 14.25rem;")
rewritten_style = rewritten_style.gsub("width:px; height:px;", "width: 320px; height: 14.25rem;")
e.set_attribute("style", rewritten_style)
end

View File

@ -33,13 +33,13 @@ describe DataFixup::SetSizingForMediaAttachmentIframes do
quiz_description = "<iframe style=\"width: px; height: px;\" src=\"/media_attachments_iframe/whatever\"></iframe>"
question_text_1 = "<iframe style=\"width: px; height: px;\" src=\"/media_attachments_iframe/whatever\"></iframe>"
question_text_2 = "<iframe style=\"width: px; height: px;\" src=\"/media_attachments_iframe/whatever\"></iframe>"
question_text_3 = "<iframe style=\"width: px; height: px;\" src=\"/media_attachments_iframe/whatever\"></iframe>"
question_text_3 = "<iframe style=\"width:px; height:px;\" src=\"/media_attachments_iframe/whatever\"></iframe>"
answer_text_1 = "<iframe style=\"width: px; height: px;\" src=\"/media_attachments_iframe/whatever\"></iframe>"
answer_text_2 = "<iframe style=\"width: px; height: px;\" src=\"/media_attachments_iframe/whatever\"></iframe>"
answer_text_3 = "<iframe style=\"width: px; height: px;\" src=\"/media_attachments_iframe/whatever\"></iframe>"
answer_text_4 = "<iframe style=\"width: px; height: px;\" src=\"/media_attachments_iframe/whatever\"></iframe>"
answer_text_5 = "<iframe style=\"width: px; height: px;\" src=\"/media_attachments_iframe/whatever\"></iframe>"
answer_text_6 = "<iframe style=\"width: px; height: px;\" src=\"/media_attachments_iframe/whatever\"></iframe>"
answer_text_6 = "<iframe style=\"width:px; height:px;\" src=\"/media_attachments_iframe/whatever\"></iframe>"
quiz_data = [
{
"question_text" => question_text_1,