How to add a slash ('/') character (or any other special characters) in text overlays?

Follow

Comments

7 comments

  • Avatar
    Nick Carey

    That took some finding ...

    0
    Comment actions Permalink
  • Avatar
    Salil Sethi

    when I double escape the following string and send it over

     

    "The arrangement covers the movie studio 20th Century Fox, the company’s TV production arm 20th Century Fox Television, Fox-owned cable networks (including FX and National Geographic), and the company’s stakes in international networks like Star TV and Sky (which Fox is planning to acquire full ownership of before" 

    I'm receiving the following image with encoding characters

    0
    Comment actions Permalink
  • Avatar
    Roee Ben Ari

    Hi Salil,

    In order to get a valid URL, please use encodeURIComponent instead of escape, like this:

    overlayText = encodeURIComponent(encodeURIComponent(text));

    You can read more about the difference between the two methods here:

    http://xkr.us/articles/javascript/encode-compare/

     

    0
    Comment actions Permalink
  • Avatar
    Lowell Chayadi

    hello, how about % character, I tried double-escape for that, but the node js library state that it's failing to decode URI malformed

    0
    Comment actions Permalink
  • Avatar
    Raya Straus

    Hi Lowell,

    Can you please share with us your implementation? 

    0
    Comment actions Permalink
  • Avatar
    Ritchie Argue

    This is a super helpful article that is unnecessarily hard to find relative to the text overlay docs, which lead the reader in a totally different direction, which only mentions single encoding rather than double encoding:

    > Important
    >Text strings containing special characters need to be modified (escaped) for use with the text overlay feature. This is relevant for any special characters that would not be allowed “as is” in a valid URL path, as well as other special unicode characters. These text strings should be escaped using % based encoding to ensure the text string is valid (for example, replacing ? with %3F and using %20 for spacing between words). This encoding is done automatically when embedding images using the Cloudinary SDK helper methods and only needs to be done when manually adding the image delivery URL.

    Why don't the SDKs automatically do this double-encoding if it's so critical? The node.js SDK doesn't seem to mind accepting a string with special characters in it, and without validation it generates invalid cloudinary URLs (single-escaped only, per the above note). To get the SDK to work, I currently manually double-escape strings, run the SDK with a placeholder token, and then manipulate the resulting SDK-generated URL with a token substitution.

    How come Cloudinary's router/url parser can't keep track of escape depth instead of pushing this burden onto the developer?

    Ughhh.

    0
    Comment actions Permalink
  • Avatar
    Roee Ben Ari

    Hi Ritchie, we appreciate your feedback! I will share your inputs internally and will update on any improvements made based on that. Thanks again!

    0
    Comment actions Permalink

Please sign in to leave a comment.