mirror of https://github.com/BOINC/boinc.git
Merge pull request #3040 from drshawnkwang/drupal_fix-bbcode-emailfilter
Drupal: Modified bbcode module to rewrite email addresses.
This commit is contained in:
commit
d35164258b
|
@ -179,6 +179,8 @@ features[variable][] = "bbcode_make_links_4"
|
|||
features[variable][] = "bbcode_make_links_6"
|
||||
features[variable][] = "bbcode_paragraph_breaks_4"
|
||||
features[variable][] = "bbcode_paragraph_breaks_6"
|
||||
features[variable][] = "bbcode_rewrite_email_4"
|
||||
features[variable][] = "bbcode_rewrite_email_6"
|
||||
features[variable][] = "boinctranslate_filter_debug_4"
|
||||
features[variable][] = "boinctranslate_filter_nodetypes"
|
||||
features[variable][] = "comment_anonymous_page"
|
||||
|
|
|
@ -111,7 +111,9 @@ function boinc_standard_input_formats() {
|
|||
// Spam link deterrent
|
||||
'bbcode_filter_nofollow' => '0',
|
||||
// Email address encoding
|
||||
'bbcode_encode_mailto' => '1',
|
||||
'bbcode_encode_mailto' => '0',
|
||||
// Email address rewrite
|
||||
'bbcode_rewrite_email' => '1',
|
||||
// Smart paragraph and line breaks
|
||||
'bbcode_paragraph_breaks' => '2',
|
||||
// Print debugging info
|
||||
|
|
|
@ -31,14 +31,14 @@ function boinc_standard_strongarm() {
|
|||
$strongarm->disabled = FALSE; /* Edit this to true to make a default strongarm disabled initially */
|
||||
$strongarm->api_version = 1;
|
||||
$strongarm->name = 'bbcode_encode_mailto_4';
|
||||
$strongarm->value = '1';
|
||||
$strongarm->value = '0';
|
||||
$export['bbcode_encode_mailto_4'] = $strongarm;
|
||||
|
||||
$strongarm = new stdClass;
|
||||
$strongarm->disabled = FALSE; /* Edit this to true to make a default strongarm disabled initially */
|
||||
$strongarm->api_version = 1;
|
||||
$strongarm->name = 'bbcode_encode_mailto_6';
|
||||
$strongarm->value = '1';
|
||||
$strongarm->value = '0';
|
||||
$export['bbcode_encode_mailto_6'] = $strongarm;
|
||||
|
||||
$strongarm = new stdClass;
|
||||
|
@ -83,6 +83,20 @@ function boinc_standard_strongarm() {
|
|||
$strongarm->value = '2';
|
||||
$export['bbcode_paragraph_breaks_6'] = $strongarm;
|
||||
|
||||
$strongarm = new stdClass;
|
||||
$strongarm->disabled = FALSE; /* Edit this to true to make a default strongarm disabled initially */
|
||||
$strongarm->api_version = 1;
|
||||
$strongarm->name = 'bbcode_rewrite_email_4';
|
||||
$strongarm->value = '1';
|
||||
$export['bbcode_rewrite_email_4'] = $strongarm;
|
||||
|
||||
$strongarm = new stdClass;
|
||||
$strongarm->disabled = FALSE; /* Edit this to true to make a default strongarm disabled initially */
|
||||
$strongarm->api_version = 1;
|
||||
$strongarm->name = 'bbcode_rewrite_email_6';
|
||||
$strongarm->value = '1';
|
||||
$export['bbcode_rewrite_email_6'] = $strongarm;
|
||||
|
||||
$strongarm = new stdClass;
|
||||
$strongarm->disabled = FALSE; /* Edit this to true to make a default strongarm disabled initially */
|
||||
$strongarm->api_version = 1;
|
||||
|
|
|
@ -269,6 +269,11 @@ function _bbcode_filter_process(&$body, $format = -1) {
|
|||
$body);
|
||||
}
|
||||
|
||||
// Re-write email addresses
|
||||
if (variable_get("bbcode_rewrite_email_$format", 1)) {
|
||||
$body = preg_replace('#((?<=^|[\t\r\n >\(\[\]\|]))([a-z0-9\-_.]+?)@([\w\-]+\.([\w\-\.]+\.)*[\w]+)#i', '\\1\\2-[at]-\\3', $body);
|
||||
}
|
||||
|
||||
// Turns web and e-mail addresses into clickable links
|
||||
if (variable_get("bbcode_make_links_$format", 1)) {
|
||||
|
||||
|
@ -290,10 +295,11 @@ function _bbcode_filter_process(&$body, $format = -1) {
|
|||
|
||||
// matches an email@domain type address at the start of a line, or after a space.
|
||||
// Note: Only the followed chars are valid; alphanums, "-", "_" and or ".".
|
||||
if (variable_get("bbcode_encode_mailto_$format", 1))
|
||||
$ret = preg_replace_callback("#([\t\r\n ])([a-z0-9\-_.]+?)@([\w\-]+\.([\w\-\.]+\.)*[\w]+)#i", '_bbcode_encode_mailto', $ret);
|
||||
else
|
||||
$ret = preg_replace('#([\t\r\n ])([a-z0-9\-_.]+?)@([\w\-]+\.([\w\-\.]+\.)*[\w]+)#i', '\\1<a href="mailto:\\2@\\3">\\2@\\3</a>', $ret);
|
||||
if (variable_get("bbcode_encode_mailto_$format", 1)) {
|
||||
$ret = preg_replace_callback("#((?<=^|[\t\r\n >\(\[\]\|]))([a-z0-9\-_.]+?)@([\w\-]+\.([\w\-\.]+\.)*[\w]+)#i", '_bbcode_encode_mailto', $ret);
|
||||
} else {
|
||||
$ret = preg_replace('#((?<=^|[\t\r\n >\(\[\]\|]))([a-z0-9\-_.]+?)@([\w\-]+\.([\w\-\.]+\.)*[\w]+)#i', '\\1<a href="mailto:\\2@\\3">\\2@\\3</a>', $ret);
|
||||
}
|
||||
|
||||
// Remove our padding
|
||||
$ret = str_replace("\x07", '', $ret);
|
||||
|
|
|
@ -79,6 +79,13 @@ function bbcode_filter($op, $delta = 0, $format = -1, $text = '') {
|
|||
'#default_value' => variable_get("bbcode_encode_mailto_$format", 1),
|
||||
'#options' => array(t('Disabled'), t('Enabled')),
|
||||
'#description' => t('Whether to encode email addresses with javascript. With this method you will have clickable mailto links, but it will be a bit harder for spam robots to collect them.'));
|
||||
$form['bbcode_filter']["bbcode_rewrite_email_$format"] = array(
|
||||
'#type' => 'select',
|
||||
'#title' => t('Email address rewrite'),
|
||||
'#default_value' => variable_get("bbcode_rewrite_email_$format", 1),
|
||||
'#options' => array(t('Disabled'), t('Enabled')),
|
||||
'#description' => t('Whether to rewrite email addresses, replacing the "@" symbol with "-[at]-". This will be a bit harder for spam robots to collect them. If enabled, the "Convert addresses to links" option is ignored. And the "Email address encoding" is ignored.'),
|
||||
);
|
||||
$form['bbcode_filter']["bbcode_paragraph_breaks_$format"] = array(
|
||||
'#type' => 'select',
|
||||
'#title' => t('Smart paragraph and line breaks'),
|
||||
|
|
Loading…
Reference in New Issue