From 2858e3f98d04ccae746d30492d7b1931c6f2a0c6 Mon Sep 17 00:00:00 2001 From: Shawn Kwang Date: Wed, 27 Feb 2019 12:43:36 -0600 Subject: [PATCH] Drupal: Modified bbcode module to change email addresses. Added variable to rewrite email addresses. Addresses will appear as username-[at]-domain.tld. This option overrides the 'convert to link' and 'encode email address' options. https://dev.gridrepublic.org/browse/DBOINCP-487 --- .../boinc/modules/contrib/bbcode/bbcode-filter.inc | 14 ++++++++++---- .../boinc/modules/contrib/bbcode/bbcode.module | 7 +++++++ 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/drupal/sites/default/boinc/modules/contrib/bbcode/bbcode-filter.inc b/drupal/sites/default/boinc/modules/contrib/bbcode/bbcode-filter.inc index 16992df8d7..0c1a5a1a8d 100644 --- a/drupal/sites/default/boinc/modules/contrib/bbcode/bbcode-filter.inc +++ b/drupal/sites/default/boinc/modules/contrib/bbcode/bbcode-filter.inc @@ -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\\2@\\3', $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\\2@\\3', $ret); + } // Remove our padding $ret = str_replace("\x07", '', $ret); diff --git a/drupal/sites/default/boinc/modules/contrib/bbcode/bbcode.module b/drupal/sites/default/boinc/modules/contrib/bbcode/bbcode.module index 6f5e76f902..42d54e39ba 100644 --- a/drupal/sites/default/boinc/modules/contrib/bbcode/bbcode.module +++ b/drupal/sites/default/boinc/modules/contrib/bbcode/bbcode.module @@ -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'),