text
stringlengths 0
828
|
---|
escape(str(linkattrd[key]), quote=True) + '""'
|
for key in linkattrd.keys()]
|
else:
|
attributes = [str(key) + '=""' + str(linkattrd[key]) + '""'
|
for key in linkattrd.keys()]
|
output += attributes_separator.join(attributes)
|
output = wash_for_utf8(output)
|
output += '>' + wash_for_utf8(link_label) + '</a>'
|
return output"
|
4738,"def create_html_mailto(
|
email,
|
subject=None,
|
body=None,
|
cc=None,
|
bcc=None,
|
link_label=""%(email)s"",
|
linkattrd=None,
|
escape_urlargd=True,
|
escape_linkattrd=True,
|
email_obfuscation_mode=None):
|
""""""Creates a W3C compliant 'mailto' link.
|
Encode/encrypt given email to reduce undesired automated email
|
harvesting when embedded in a web page.
|
NOTE: there is no ultimate solution to protect against email
|
harvesting. All have drawbacks and can more or less be
|
circumvented. There are other techniques to protect email
|
addresses. We implement the less annoying one for users.
|
@param email: the recipient of the email
|
@param subject: a default subject for the email (must not contain
|
line feeds)
|
@param body: a default body for the email
|
@param cc: the co-recipient(s) of the email
|
@param bcc: the hidden co-recpient(s) of the email
|
@param link_label: the label of this mailto link. String
|
replacement is performed on key %(email)s with
|
the email address if needed.
|
@param linkattrd: dictionary of attributes (e.g. a={'class': 'img'})
|
@param escape_urlargd: boolean indicating if the function should escape
|
arguments (e.g. < becomes < or "" becomes ")
|
@param escape_linkattrd: boolean indicating if the function should escape
|
attributes (e.g. < becomes < or "" becomes ")
|
@param email_obfuscation_mode: the protection mode. See below:
|
You can choose among several modes to protect emails. It is
|
advised to keep the default
|
CFG_MISCUTIL_EMAIL_HARVESTING_PROTECTION value, so that it is
|
possible for an admin to change the policy globally.
|
Available modes ([t] means ""transparent"" for the user):
|
-1: hide all emails, excepted CFG_SITE_ADMIN_EMAIL and
|
CFG_SITE_SUPPORT_EMAIL.
|
[t] 0 : no protection, email returned as is.
|
foo@example.com => foo@example.com
|
1 : basic email munging: replaces @ by [at] and . by [dot]
|
foo@example.com => foo [at] example [dot] com
|
[t] 2 : transparent name mangling: characters are replaced by
|
equivalent HTML entities.
|
foo@example.com => foo@example.com
|
[t] 3 : javascript insertion. Requires Javascript enabled on client side.
|
4 : replaces @ and . characters by gif equivalents.
|
foo@example.com => foo<img src=""at.gif"" alt="" [at] "">example<img src=""dot.gif"" alt="" [dot] "">com
|
""""""
|
# TODO: implement other protection modes to encode/encript email:
|
#
|
# [t] 5 : form submission. User is redirected to a form that he can
|
# fills in to send the email (??Use webmessage??).
|
# Depending on WebAccess, ask to answer a question.
|
##
|
# [t] 6 : if user can see (controlled by WebAccess), display. Else
|
# ask to login to see email. If user cannot see, display
|
# form submission.
|
if email_obfuscation_mode is None:
|
email_obfuscation_mode = cfg.get(
|
'CFG_WEBSTYLE_EMAIL_ADDRESSES_OBFUSCATION_MODE')
|
if linkattrd is None:
|
linkattrd = {}
|
parameters = {}
|
if subject:
|
parameters[""subject""] = subject
|
if body:
|
parameters[""body""] = body.replace('\r\n', '\n').replace('\n', '\r\n')
|
if cc:
|
parameters[""cc""] = cc
|
if bcc:
|
parameters[""bcc""] = bcc
|
# Preprocessing values for some modes
|
if email_obfuscation_mode == 1:
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.