Skip to content

Commit fe818b6

Browse files
committed
Make email obfuscation optional
1 parent a2c0f72 commit fe818b6

File tree

2 files changed

+41
-19
lines changed

2 files changed

+41
-19
lines changed

src/config.xml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3909,6 +3909,14 @@ If the \c DOT_CLEANUP tag is set to \c YES, doxygen will
39093909
remove the intermediate files that are used to generate the various graphs.
39103910
<br>Note:
39113911
This setting is not only used for dot files but also for msc temporary files.
3912+
]]>
3913+
</docs>
3914+
</option>
3915+
<option type='bool' id='OBFUSCATE_EMAILS' defval='1'>
3916+
<docs>
3917+
<![CDATA[
3918+
If the \c OBFUSCATE_EMAILS tag is set to \c YES, doxygen will
3919+
obfuscate email addresses.
39123920
]]>
39133921
</docs>
39143922
</option>

src/htmldocvisitor.cpp

Lines changed: 33 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -353,23 +353,30 @@ void HtmlDocVisitor::visit(DocEmoji *s)
353353

354354
void HtmlDocVisitor::writeObfuscatedMailAddress(const QCString &url)
355355
{
356-
m_t << "<a href=\"#\" onclick=\"location.href='mai'+'lto:'";
357-
if (!url.isEmpty())
356+
if (!Config_getBool(OBFUSCATE_EMAILS))
358357
{
359-
const char *p = url.data();
360-
uint size=3;
361-
while (*p)
358+
m_t << "<a href=\"mailto:" << url << "\">";
359+
}
360+
else
361+
{
362+
m_t << "<a href=\"#\" onclick=\"location.href='mai'+'lto:'";
363+
if (!url.isEmpty())
362364
{
363-
m_t << "+'";
364-
for (uint j=0;j<size && *p;j++)
365+
const char *p = url.data();
366+
uint size=3;
367+
while (*p)
365368
{
366-
p = writeUTF8Char(m_t,p);
369+
m_t << "+'";
370+
for (uint j=0;j<size && *p;j++)
371+
{
372+
p = writeUTF8Char(m_t,p);
373+
}
374+
m_t << "'";
375+
if (size==3) size=2; else size=3;
367376
}
368-
m_t << "'";
369-
if (size==3) size=2; else size=3;
370377
}
378+
m_t << "; return false;\">";
371379
}
372-
m_t << "; return false;\">";
373380
}
374381

375382
void HtmlDocVisitor::visit(DocURL *u)
@@ -380,17 +387,24 @@ void HtmlDocVisitor::visit(DocURL *u)
380387
QCString url = u->url();
381388
// obfuscate the mail address link
382389
writeObfuscatedMailAddress(url);
383-
const char *p = url.data();
384-
// also obfuscate the address as shown on the web page
385-
uint size=5;
386-
while (*p)
390+
if (!Config_getBool(OBFUSCATE_EMAILS))
387391
{
388-
for (uint j=0;j<size && *p;j++)
392+
m_t << url;
393+
}
394+
else
395+
{
396+
const char *p = url.data();
397+
// also obfuscate the address as shown on the web page
398+
uint size=5;
399+
while (*p)
389400
{
390-
p = writeUTF8Char(m_t,p);
401+
for (uint j=0;j<size && *p;j++)
402+
{
403+
p = writeUTF8Char(m_t,p);
404+
}
405+
if (*p) m_t << "<span style=\"display: none;\">.nosp@m.</span>";
406+
if (size==5) size=4; else size=5;
391407
}
392-
if (*p) m_t << "<span style=\"display: none;\">.nosp@m.</span>";
393-
if (size==5) size=4; else size=5;
394408
}
395409
m_t << "</a>";
396410
}

0 commit comments

Comments
 (0)