Skip to content

Commit

Permalink
Make email obfuscation optional
Browse files Browse the repository at this point in the history
  • Loading branch information
AMDmi3 committed Dec 29, 2021
1 parent a2c0f72 commit fe818b6
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 19 deletions.
8 changes: 8 additions & 0 deletions src/config.xml
Original file line number 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.
<br>Note:
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>
</option>
Expand Down
52 changes: 33 additions & 19 deletions src/htmldocvisitor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -353,23 +353,30 @@ void HtmlDocVisitor::visit(DocEmoji *s)

void HtmlDocVisitor::writeObfuscatedMailAddress(const QCString &url)
{
m_t << "<a href=\"#\" onclick=\"location.href='mai'+'lto:'";
if (!url.isEmpty())
if (!Config_getBool(OBFUSCATE_EMAILS))
{
const char *p = url.data();
uint size=3;
while (*p)
m_t << "<a href=\"mailto:" << url << "\">";
}
else
{
m_t << "<a href=\"#\" onclick=\"location.href='mai'+'lto:'";
if (!url.isEmpty())
{
m_t << "+'";
for (uint j=0;j<size && *p;j++)
const char *p = url.data();
uint size=3;
while (*p)
{
p = writeUTF8Char(m_t,p);
m_t << "+'";
for (uint j=0;j<size && *p;j++)
{
p = writeUTF8Char(m_t,p);
}
m_t << "'";
if (size==3) size=2; else size=3;
}
m_t << "'";
if (size==3) size=2; else size=3;
}
m_t << "; return false;\">";
}
m_t << "; return false;\">";
}

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

0 comments on commit fe818b6

Please sign in to comment.