Changeset 1361997
- Timestamp:
- 03/01/2016 06:31:15 PM (11 years ago)
- Location:
- contact-form-7-to-database-extension/trunk
- Files:
-
- 1 added
- 1 edited
-
CF7DBPlugin.php (modified) (3 diffs)
-
phpunit/ParseFieldMatchesTest.php (added)
Legend:
- Unmodified
- Added
- Removed
-
contact-form-7-to-database-extension/trunk/CF7DBPlugin.php
r1334626 r1361997 1149 1149 */ 1150 1150 public function getNoSaveFields() { 1151 return preg_split('/,|;/', $this->getOption('NoSaveFields'), -1, PREG_SPLIT_NO_EMPTY);1151 return $this->parseOption($this->getOption('NoSaveFields')); 1152 1152 } 1153 1153 … … 1156 1156 */ 1157 1157 public function getNoSaveForms() { 1158 return preg_split('/,|;/', $this->getOption('NoSaveForms'), -1, PREG_SPLIT_NO_EMPTY); 1158 return $this->parseOption($this->getOption('NoSaveForms')); 1159 } 1160 1161 /** 1162 * Parse option string that is a comma-delimited set of stings (some of which may be regex's with commas in them) 1163 * @param $option string 1164 * @return array 1165 */ 1166 public function parseOption($option) { 1167 // return preg_split('/,|;/', $option, -1, PREG_SPLIT_NO_EMPTY); 1168 $values = array(); 1169 if ($option) { 1170 $regex = false; 1171 $esc = false; 1172 $value = ''; 1173 $len = strlen($option); 1174 for ($i = 0; $i < $len; $i++) { 1175 1176 if ($regex && !$esc && $option[$i] == '\\') { 1177 $esc = true; 1178 $value .= $option[$i]; 1179 continue; 1180 } 1181 1182 if (!$value && $option[$i] == '/') { 1183 $regex = true; 1184 $value .= $option[$i]; 1185 continue; 1186 } 1187 1188 if (!$regex) { 1189 if ($option[$i] == ',') { 1190 if ($value) { 1191 $values[] = $value; 1192 } 1193 $value = ''; 1194 } else { 1195 $value .= $option[$i]; 1196 } 1197 } else { 1198 if ($option[$i] == '/' && !$esc) { 1199 $regex = false; 1200 } 1201 $value .= $option[$i]; 1202 } 1203 $esc = false; 1204 } 1205 if ($value) { 1206 $values[] = $value; 1207 } 1208 } 1209 return $values; 1159 1210 } 1160 1211 … … 1163 1214 */ 1164 1215 public function getSaveCookies() { 1165 return preg_split('/,|;/', $this->getOption('SaveCookieNames'), -1, PREG_SPLIT_NO_EMPTY);1216 return $this->parseOption($this->getOption('SaveCookieNames')); 1166 1217 } 1167 1218
Note:
See TracChangeset
for help on using the changeset viewer.
![(please configure the [header_logo] section in trac.ini)](/chrome/site/your_project_logo.png)