Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Some kind of overlay texts generate urls which cause 400 Bad Request #474

Open
3 of 9 tasks
ttanimichi opened this issue Jan 15, 2022 · 7 comments
Open
3 of 9 tasks
Assignees
Labels

Comments

@ttanimichi
Copy link

Some kind of overlay texts generate urls which cause 400 Bad Request

Describe the bug in a sentence or two.

require 'open-uri'

def foo(text)
  url = Cloudinary::Utils.cloudinary_url('sample', transformation: [
    {
      overlay: {
        font_size: 24,
        font_family: 'Sawarabi%20Gothic',
        text: text
      },
    }
  ])

  URI.open(url)
end

foo('hello') # No problem
foo('hello🍺') # => 400 Bad Request (OpenURI::HTTPError)

Issue Type (Can be multiple)

  • Build - Cannot install or import the SDK
  • Performance - Performance issues
  • Behaviour - Functions are not working as expected (such as generate URL)
  • Documentation - Inconsistency between the docs and behaviour
  • Other (Specify)

Operating System

  • Linux
  • Windows
  • macOS
  • All

Environment and Libraries (fill in the version numbers)

$ bundle info cloudinary
  * cloudinary (1.21.0)
	Summary: Client library for easily using the Cloudinary service
	Homepage: http://cloudinary.com
	Path: /Users/ttanimichi/.rbenv/versions/3.0.3/lib/ruby/gems/3.0.0/gems/cloudinary-1.21.0

$ ruby -v
ruby 3.0.3p157 (2021-11-24 revision 3fb7d2cadc) [arm64-darwin21]

$ bin/rails -v
Rails 6.1.4.1
@michalkcloudinay
Copy link

Hi @ttanimichi, including emojis in text overlays can be done by double encoding the emoji as explained here:https://support.cloudinary.com/hc/en-us/articles/360003457091-How-to-overlay-emojis-in-images. Please note that not all emojis are supported. You can refer here for the list of supported emojis: https://www.piliapp.com/symbol/

@ttanimichi
Copy link
Author

ttanimichi commented Jan 16, 2022

@michalkcloudinay Thank you for your reply.
Not only emojis but also some kind of chinese characters seem to cause the same error.

foo('漢字') # Most of chinese characters are No Problem
foo('あいうえお') # Japanese Hiragana letters are also No Problem

foo('𩸽') # => 400 Bad Request (OpenURI::HTTPError)
foo('𡈽') # => 400 Bad Request (OpenURI::HTTPError)
foo('𠀋') # => 400 Bad Request (OpenURI::HTTPError)

I found that the bytesize of 🍺, 𩸽 (Unicode: U+29E3D), 𡈽 and 𠀋 are four.

$ irb
irb(main):001:0> '𩸽'.bytesize
=> 4
irb(main):002:0> '🍺'.bytesize
=> 4
irb(main):003:0> '𡈽'.bytesize
=> 4
irb(main):004:0> '𠀋'.bytesize
=> 4

Probably, overlay texts of 4-bytesize Unicode characters cause this error. Isn't it a bug of Cloudinary API, is it?

@ttanimichi
Copy link
Author

ttanimichi commented Jan 16, 2022

One of my best friend Mr. 𡈽田 (Tsuchida) can't display his name as overlay texts since his family name contains 𡈽, which is a 4-bytesize Unicode character. It's so much trouble for him...

@michalkcloudinay
Copy link

Hi @ttanimichi, for 4-bytesize Unicode characters you would need to use a double encoding. For example:
https://res.cloudinary.com/demo/image/upload/o_30/l_text:Arial_58:%2520%25F0%25A9%25B8%25BD/couple.jpg
Let us know if this works for you.

@ttanimichi
Copy link
Author

@michalkcloudinay Thanks! I'll try it next week and let you know the result

@michalkcloudinay
Copy link

Great! Let us know how it goes.

@aleksandar-cloudinary
Copy link
Contributor

Hi @ttanimichi - just wanted to follow up on this to see if you had a chance to test this and if it worked for you?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants