Skip to content

Make email obfuscation optional #8989

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Dec 30, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions src/config.xml
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -3909,6 +3909,14 @@ If the \c DOT_CLEANUP tag is set to \c YES, doxygen will
remove the intermediate files that are used to generate the various graphs. remove the intermediate files that are used to generate the various graphs.
<br>Note: <br>Note:
This setting is not only used for dot files but also for msc temporary files. This setting is not only used for dot files but also for msc temporary files.
]]>
</docs>
</option>
<option type='bool' id='OBFUSCATE_EMAILS' defval='1'>
<docs>
<![CDATA[
If the \c OBFUSCATE_EMAILS tag is set to \c YES, doxygen will
obfuscate email addresses.
]]> ]]>
</docs> </docs>
</option> </option>
Expand Down
14 changes: 14 additions & 0 deletions src/htmldocvisitor.cpp
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -352,6 +352,12 @@ void HtmlDocVisitor::visit(DocEmoji *s)
} }


void HtmlDocVisitor::writeObfuscatedMailAddress(const QCString &url) void HtmlDocVisitor::writeObfuscatedMailAddress(const QCString &url)
{
if (!Config_getBool(OBFUSCATE_EMAILS))
{
m_t << "<a href=\"mailto:" << url << "\">";
}
else
{ {
m_t << "<a href=\"#\" onclick=\"location.href='mai'+'lto:'"; m_t << "<a href=\"#\" onclick=\"location.href='mai'+'lto:'";
if (!url.isEmpty()) if (!url.isEmpty())
Expand All @@ -371,6 +377,7 @@ void HtmlDocVisitor::writeObfuscatedMailAddress(const QCString &url)
} }
m_t << "; return false;\">"; m_t << "; return false;\">";
} }
}


void HtmlDocVisitor::visit(DocURL *u) void HtmlDocVisitor::visit(DocURL *u)
{ {
Expand All @@ -380,6 +387,12 @@ void HtmlDocVisitor::visit(DocURL *u)
QCString url = u->url(); QCString url = u->url();
// obfuscate the mail address link // obfuscate the mail address link
writeObfuscatedMailAddress(url); writeObfuscatedMailAddress(url);
if (!Config_getBool(OBFUSCATE_EMAILS))
{
m_t << url;
}
else
{
const char *p = url.data(); const char *p = url.data();
// also obfuscate the address as shown on the web page // also obfuscate the address as shown on the web page
uint size=5; uint size=5;
Expand All @@ -392,6 +405,7 @@ void HtmlDocVisitor::visit(DocURL *u)
if (*p) m_t << "<span style=\"display: none;\">.nosp@m.</span>"; if (*p) m_t << "<span style=\"display: none;\">.nosp@m.</span>";
if (size==5) size=4; else size=5; if (size==5) size=4; else size=5;
} }
}
m_t << "</a>"; m_t << "</a>";
} }
else // web address else // web address
Expand Down