Skip to content

[Bug]: URIError: URI malformed from encodeURIComponent #692

@cabello

Description

@cabello

What happened?

When clicking "add to Apple" button, the button would do nothing, upon checking console log and error was present.

I inspected the produced code and put a few breaking points and noticed that the description was being split with \r\n in many places, sometimes mid-sentence. e.g. I eit\r\n her am still

I suspect atcb_rewrite_ical_text in atcb-util.js breaks unicode text at wrong places causing this error.

For example, I got this: lobby ☺️\ud83d\r\n \udc97\\nI am for the X-ALT-DESC;FMTTYPE=text/html portion of the calendar data.

In that function truncate defaults to true

if (truncate) {
    // adjusting for intended line breaks + making sure it does not exceed 75 characters per line
    content = content.replace(/.{60}/g, '$&' + '\r\n ');
  }

By splitting the unicode sequence in multiple lines the text cannot be encoded as expected. Correct behaviour would be to add \r\n before or after the unicode sequence.

How to reproduce?

Have a long description like this:

"Tattoo appointment with @besinkartnation.
Note: <p>Please let me know when you’ve arrived and I will buzz you in! In the case that I cannot buzz you in because I either am still in a session or haven’t arrived yet, you will be given a code to let yourself in and wait in the lobby ☺️💗</p><p>I am in Suite 10. Down the hallway, just take a right and keep walking straight until you see the number 10! Please reach out if you have any difficulties at all &lt;33</p>"

The key is some emojis that might be split at wrong places. Emojis that may are represented using multiple code points, e.g skin colors.

When clicking the add to calendar button, nothing happens, check the console to see the error:

atcb-DugYzGb2.js:82 Uncaught URIError: URI malformed
    at encodeURIComponent (<anonymous>)
    at atcb-DugYzGb2.js:82:1139

Screenshots & more

No response

System & Environment

  1. Device and OS: macOS, desktop
  2. Browser: Chrome
  3. Version number of the application: 2.8.5
  4. How you include the script: add-to-calendar-button-react

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions