Project

General

Profile

« Previous | Next » 

Revision 884

Added by doc about 16 years ago

updated output filter regex to exclude mail addresses contained in input fields

View differences:

trunk/CHANGELOG
10 10
# = Bugfix
11 11
! = Update/Change
12 12

  
13
------------------------------------- 2.7.1 -------------------------------------
14
27-Nov-2008 Thomas Hornik
13
------------------------------------- 2.7.1 -------------------------------------
14
28-Oct-2008 Christian Sommer
15
!	updated output filter regex to exclude mail addresses contained in input fields
16
27-Nov-2008 Thomas Hornik
15 17
!	added redirect-type (301/302) to menu_link
16 18
24-Nov-2008 Matthias Gallas
17 19
!	updated upgrade-script.php to add sec_anchor field to settings table
trunk/wb/modules/output_filter/filter-routines.php
91 91
		// first search part to find all mailto email addresses
92 92
		$pattern = '#(<a[^<]*href\s*?=\s*?"\s*?mailto\s*?:\s*?)([A-Z0-9._%+-]+@(?:[A-Z0-9-]+\.)+[A-Z]{2,4})([^"]*?)"([^>]*>)(.*?)</a>';
93 93
		// second part to find all non mailto email addresses
94
		$pattern .= '|\b([A-Z0-9._%+-]+@(?:[A-Z0-9-]+\.)+[A-Z]{2,4})\b#i';
94
		$pattern .= '|(value\s*=\s*"|\')??\b([A-Z0-9._%+-]+@(?:[A-Z0-9-]+\.)+[A-Z]{2,4})\b#i';
95 95
		/*
96 96
		Sub 1:\b(<a.[^<]*href\s*?=\s*?"\s*?mailto\s*?:\s*?)			-->	"<a id="yyy" class="xxx" href = " mailto :" ignoring white spaces
97 97
		Sub 2:([A-Z0-9._%+-]+@(?:[A-Z0-9-]+\.)+[A-Z]{2,4})			-->	the email address in the mailto: part of the mail link
......
120 120
		$search = array('@', '.');
121 121
		$replace = array(OUTPUT_FILTER_AT_REPLACEMENT ,OUTPUT_FILTER_DOT_REPLACEMENT);
122 122
		
123
		// check if the match contains the expected number of subpatterns (6|7)
124
		if(count($match) == 7) {
123
		// check if the match contains the expected number of subpatterns (6|8)
124
		if(count($match) == 8) {
125 125
			/**
126 126
				OUTPUT FILTER FOR EMAIL ADDRESSES EMBEDDED IN TEXT
127 127
			**/
128 128
			
129 129
			// 1.. text mails only, 3.. text mails + mailto (no JS), 7 text mails + mailto (JS)
130 130
			if(!in_array(OUTPUT_FILTER_MODE, array(1,3,7))) return $match[0];
131

  
132
			// do not filter mail addresses included in input tags (<input ... value = "test@mail)
133
			if (strpos($match[6], 'value') !== false) return $match[0];
131 134
			
132 135
			// filtering of non mailto email addresses enabled
133 136
			return str_replace($search, $replace, $match[0]);

Also available in: Unified diff