Created
September 16, 2021 10:27
-
-
Save bennadel/615e5fd3d8adb470a2a69be94356ce80 to your computer and use it in GitHub Desktop.
Yahoo! Mail Does Not Render Anchor Tags With Encoded HREF Attributes
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<h1> | |
You've been invited to a project | |
</h1> | |
<p> | |
Ben Nadel has invited you to join | |
<a href="https://projects.invisionapp.com/path/to/project#/spa/path">My Awesome Project</a>, | |
an InVision project. | |
</p> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<cfscript> | |
// Setup data to be used in email-template rendering. | |
project = { | |
owner: "Ben Nadel", | |
name: "My Awesome Project", | |
url: "https://projects.invisionapp.com/path/to/project##/spa/path" | |
}; | |
</cfscript> | |
<cfoutput> | |
<h1> | |
You've been invited to a project | |
</h1> | |
<p> | |
#encodeForHtml( project.owner )# has invited you to join | |
<a href="#encodeForHtmlAttribute( project.url )#">#encodeForHtml( project.name )#</a>, | |
an InVision project. | |
</p> | |
</cfoutput> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<h1> | |
You've been invited to a project | |
</h1> | |
<p> | |
Ben Nadel has invited you to join | |
<a href="https://projects.invisionapp.com/path/to/project#/spa/path">My Awesome Project</a>, | |
an InVision project. | |
</p> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<cfscript> | |
// Setup data to be used in email-template rendering. | |
project = { | |
owner: "Ben Nadel", | |
name: "My Awesome Project", | |
url: "https://projects.invisionapp.com/path/to/project##/spa/path" | |
}; | |
</cfscript> | |
<cfoutput> | |
<h1> | |
You've been invited to a project | |
</h1> | |
<p> | |
#encodeForHtml( project.owner )# has invited you to join | |
<a href="#encodeForHrefAttribute( project.url )#">#encodeForHtml( project.name )#</a>, | |
an InVision project. | |
</p> | |
</cfoutput> | |
<cfscript> | |
/** | |
* I encoded the given value for use in an HREF attribute. This is designed to reduce | |
* the amount of encoded characters so as to make the resultant value a little more | |
* mail-client friendly. | |
*/ | |
public string function encodeForHrefAttribute( required string value ) { | |
var encodedValue = encodeForHtmlAttribute( value ); | |
// The encodeForHtmlAttribute() function will encode just about any non-alpha- | |
// numeric character. Which, in most cases is completely fine. But, for Yahoo! | |
// Mail, we need to back that encoding off just a bit, unencoding the protocol | |
// suffix. | |
var unencodedSuffix = "://"; | |
var encodedSuffix = encodeForHtmlAttribute( unencodedSuffix ); | |
// Replace the encoded protocol with the unencoded version. | |
var fixedValue = encodedValue.reReplaceNoCase( | |
"^([a-z0-9]+)#encodedSuffix#", | |
"\1#unencodedSuffix#" | |
); | |
return( fixedValue ); | |
} | |
</cfscript> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment