Skip to content

URI malformed error when link content contains tab character #18

@matthewsmith-io

Description

@matthewsmith-io

When I use javascript encoding and the link content contains tab characters, Chrome says:
Uncaught URIError: URI malformed at decodeURIComponent (<anonymous>)

It seems decodeURIComponent is getting hung up on improperly encoded tab characters.

Removing the tab characters fixes the error.

I have tab characters because I'm using an ERB block:

<%= mail_to @job_posting.contact_email, encode: 'javascript' do -%>
	Apply Now <img src="arrow.png">
<% end -%>

The obvious work-around is to not indent my code... But that's not a real solution.

I pulled the encoded string from Chrome's Sources tab and can see that the tab characters have been encoded as %9 instead of %09.

But shouldn't leading whitespace characters be stripped anyway? Because even if it did successfully encode the tab characters, they would appear in the output, which is obviously undesired.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions