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

Spaces in Font's name are not escaped #458

Open
tejanium opened this issue Jul 23, 2021 · 6 comments
Open

Spaces in Font's name are not escaped #458

tejanium opened this issue Jul 23, 2021 · 6 comments

Comments

@tejanium
Copy link

Cloudinary supports all of Google's fonts https://support.cloudinary.com/hc/en-us/articles/203352832-What-is-the-list-of-supported-fonts-for-text-overlay-transformation- and some of them have spaces on them, for example, "Open Sans"

But unlike Text Transformation where spaces are escaped

text = result + smart_escape( smart_escape(text, %r"([,/])"))
font family aren't
keywords.unshift(font_family)

resulting in an invalid URL

[1] pry(main)> Cloudinary::VERSION
=> "1.20.0"
[2] pry(main)> url = Cloudinary::Utils.cloudinary_url("coffee_cup.jpg", transformation: [
  {overlay: {font_family: "Open Sans", text: "Text with spaces", font_size: 10}}
])
=> "http://res.cloudinary.com/cookpad/image/upload/l_text:Open Sans_10:Text%20with%20spaces/coffee_cup.jpg"
[3] pry(main)> URI.parse url
URI::InvalidURIError: bad URI(is not URI?): "http://res.cloudinary.com/cookpad/image/upload/l_text:Open Sans_10:Text%20with%20spaces/coffee_cup.jpg"
@tommyg-cld
Copy link
Contributor

@tejanium firstly apologies for the delay in getting back here, this got lost in our backlog.

Regarding the customer font, you can just URL encode the space before making the request and it will work e.g. https://res.cloudinary.com/cookpad/image/upload/l_text:Open%20Sans_60:Text%20with%20spaces/sample.jpg

let me know if resolves your issue?

@tejanium
Copy link
Author

Thank you for getting back to me

Regarding the customer font, you can just URL encode the space before making the request and it will work e.g. res.cloudinary.com/cookpad/image/upload/l_text:Open%20Sans_60:Text%20with%20spaces/sample.jpg

Yes, this is what we ended up doing. But I think this should be part of the library.

@tommyg-cld
Copy link
Contributor

@tejanium no problem and fair point, let me raise it internally and hopefully we will have a fix soon.

@tommyg-cld
Copy link
Contributor

also as a workaround, for now, you could escape the space when it comes to fonts with spaces like font_family: "Open%20Sans"

@tejanium
Copy link
Author

Yes, that's what we did

        def safe_font_family
          ERB::Util.url_encode(font_family)
        end

@tommyg-cld
Copy link
Contributor

so this is in our list to fix but no ETA currently but will keep you posted.

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

No branches or pull requests

2 participants