Skip to content

Commit 54c208d

Browse files
authored
Merge pull request #1492 from cypht-org/strip_dns_prefetch_tags
feat(other): add strip_dns_prefetch_tags for the html
2 parents d90852d + ad1dddc commit 54c208d

File tree

2 files changed

+17
-5
lines changed

2 files changed

+17
-5
lines changed

modules/core/message_functions.php

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,17 @@ function format_msg_text($str, $output_mod, $links=true) {
7575
return preg_replace("/^(&gt;.*<br \/>)/m", "<span class=\"reply_quote\">$1</span>", $str);
7676
}}
7777

78+
/**
79+
* Strip DNS prefetch tags from HTML
80+
* @subpackage core/functions
81+
* @param string $html HTML content
82+
* @return string
83+
*/
84+
if (!hm_exists('strip_dns_prefetch_tags')) {
85+
function strip_dns_prefetch_tags($html) {
86+
return preg_replace('/<link\s+[^>]*rel=["\']dns-prefetch["\'][^>]*>/i', '', $html);
87+
}}
88+
7889
/**
7990
* Format reply text
8091
* @subpackage core/functions
@@ -119,7 +130,7 @@ function reply_to_address($headers, $type) {
119130
return $msg_to;
120131
}
121132
foreach (array('reply-to', 'from', 'sender', 'return-path') as $fld) {
122-
if (array_key_exists($fld, $headers)) {
133+
if (array_key_exists($fld, $headers)) {
123134
list($parsed, $msg_to) = format_reply_address($headers[$fld], $parsed);
124135
if ($msg_to) {
125136
break;
@@ -485,7 +496,7 @@ function addr_split($str, $seps = array(',', ';')) {
485496
elseif (!$capture && in_array($str[$i], array_keys($capture_chars))) {
486497
$capture = $str[$i];
487498
}
488-
499+
489500
if (!$capture && in_array($str[$i], $seps)) {
490501
$words[] = trim($word);
491502
$word = '';

modules/imap/output_modules.php

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,7 @@ protected function output() {
124124
$txt .= format_msg_text($this->get('msg_text'), $this);
125125
}
126126
}
127+
$msg_text = strip_dns_prefetch_tags('msg_text');
127128
}
128129
$txt .= '</div>';
129130
$this->out('msg_text', $txt);
@@ -229,7 +230,7 @@ protected function output() {
229230
if ($this->get('list_headers')) {
230231
$txt .= format_list_headers($this);
231232
}
232-
$lc_headers = lc_headers($headers);
233+
$lc_headers = lc_headers($headers);
233234
if (array_key_exists('to', $lc_headers)) {
234235
$addr_list = process_address_fld($lc_headers['to']);
235236
$size = count($addr_list);
@@ -247,7 +248,7 @@ protected function output() {
247248
});
248249
$size += count($addr_list);
249250
}
250-
251+
251252
$txt .= '<tr><td class="header_space" colspan="2"></td></tr>';
252253
$txt .= '<tr><th colspan="2" class="header_links">';
253254
$txt .= '<div class="msg_move_to">'.
@@ -386,7 +387,7 @@ protected function output() {
386387
$default_value = '';
387388
if (isset($vals['sieve_config_host'])) {
388389
$default_value = $vals['sieve_config_host'];
389-
390+
390391
$res .= '<span><label class="screen_reader" for="imap_sieve_host_'.$index.'">'.$this->trans('Sieve Host').'</label>'.
391392
'<input '.$disabled.' id="imap_sieve_host_'.$index.'" class="credentials imap_sieve_host_input" placeholder="Sieve Host" type="text" name="imap_sieve_host" value="'.$default_value.'"></span>';
392393
}

0 commit comments

Comments
 (0)