-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathemail-obfuscation.xsl
45 lines (37 loc) · 1.36 KB
/
email-obfuscation.xsl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<!--
Email Obfuscation
Requires JavaScript to re-compile the email address
@package Utility Monkey
@author John Porter <[email protected]>
@license CC0 <http://creativecommons.org/publicdomain/zero/1.0/>
-->
<xsl:template name="obfuscated-email">
<xsl:param name="node"/>
<xsl:param name="classes" select="''"/>
<xsl:variable name="string">
<xsl:choose>
<xsl:when test="$node/@href">
<xsl:value-of select="@href"/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="$node/text()"/>
</xsl:otherwise>
</xsl:choose>
</xsl:variable>
<xsl:element name="a">
<xsl:choose>
<xsl:when test="starts-with($string, 'mailto')">
<xsl:attribute name="data-identity"><xsl:value-of select="substring-after(substring-before($string,'@'), ':')"/></xsl:attribute>
</xsl:when>
<xsl:otherwise>
<xsl:attribute name="data-domain"><xsl:value-of select="substring-after($string,'@')"/></xsl:attribute>
</xsl:otherwise>
</xsl:choose>
<xsl:attribute name="data-domain"><xsl:value-of select="substring-after($string,'@')"/></xsl:attribute>
<xsl:attribute name="class">obfuscated <xsl:value-of select="$classes"/></xsl:attribute>
<xsl:attribute name="href">#</xsl:attribute>
</xsl:element>
</xsl:template>
</xsl:stylesheet>