Skip to content

Commit

Permalink
Merge pull request #5 from performant-software/feature/udcsl671_encod…
Browse files Browse the repository at this point in the history
…ings

Force ASCII_8BIT encoding in POST request bodies (UDCSL #671)
  • Loading branch information
blms authored Jan 11, 2023
2 parents 38c0826 + 8ae19dc commit 39b7650
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions app/services/triple_eye_effable/cloud.rb
Original file line number Diff line number Diff line change
Expand Up @@ -76,18 +76,26 @@ def parse_response(response)
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)
metadata = resourceable.metadata if resourceable.respond_to?(:metadata)

{
body = {
resource: {
project_id: @project_id,
name: name,
content: content,
metadata: metadata
}
}

# Only send content if it's being changed
if content.present?
# handle unicode in original_filename
content.original_filename = content.original_filename.force_encoding(Encoding::ASCII_8BIT)
body[:resource][:content] = content
end

body
end
end
end

0 comments on commit 39b7650

Please sign in to comment.