From fecbf82b209c51be1597d6737c120a7f3199044f Mon Sep 17 00:00:00 2001 From: Ben Silverman Date: Mon, 19 Dec 2022 12:00:00 -0500 Subject: [PATCH 1/2] Force ASCII_8BIT encoding in POST req (UDCSL #671) --- app/services/triple_eye_effable/cloud.rb | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/app/services/triple_eye_effable/cloud.rb b/app/services/triple_eye_effable/cloud.rb index 750f40b..5bbebc4 100644 --- a/app/services/triple_eye_effable/cloud.rb +++ b/app/services/triple_eye_effable/cloud.rb @@ -89,7 +89,7 @@ def populate_description(resource_description, data) end def request_body(resourceable) - name = resourceable.name if resourceable.respond_to?(:name) + name = resourceable.name.force_encoding(Encoding::ASCII_8BIT) if resourceable.respond_to?(:name) content = resourceable.content if resourceable.respond_to?(:content) content_remove = resourceable.content_remove if resourceable.respond_to?(:content_remove) metadata = resourceable.metadata if resourceable.respond_to?(:metadata) @@ -103,7 +103,11 @@ def request_body(resourceable) } # Only send content if it's being changed - body[:resource][:content] = content if content.present? + if content.present? + # handle unicode in original_filename + content.original_filename = content.original_filename.force_encoding(Encoding::ASCII_8BIT) + body[:resource][:content] = content if content.present? + end body end From 16f51f47f6eedfea49b5a1906754b02593e1394b Mon Sep 17 00:00:00 2001 From: Ben Silverman Date: Mon, 19 Dec 2022 12:00:30 -0500 Subject: [PATCH 2/2] Remove redundant conditional --- app/services/triple_eye_effable/cloud.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/services/triple_eye_effable/cloud.rb b/app/services/triple_eye_effable/cloud.rb index 5bbebc4..85808b4 100644 --- a/app/services/triple_eye_effable/cloud.rb +++ b/app/services/triple_eye_effable/cloud.rb @@ -106,7 +106,7 @@ def request_body(resourceable) if content.present? # handle unicode in original_filename content.original_filename = content.original_filename.force_encoding(Encoding::ASCII_8BIT) - body[:resource][:content] = content if content.present? + body[:resource][:content] = content end body