Ticket #9959: 9959.patch
File 9959.patch, 1.3 KB (added by , 15 years ago) |
---|
-
formatting.php
1270 1270 global $wpdb; 1271 1271 // This is a pre save filter, so text is already escaped. 1272 1272 $text = stripslashes($text); 1273 $text = preg_replace_callback('|<a (.+?)>|i', 'wp_rel_nofollow_callback', $text); 1273 $r = array( 1274 "|(<a\b[^>]*?\srel=['\"])(?![^'\"]*\bnofollow\b)|i" => "$1nofollow ", 1275 "|<a\b(?![^>]*\srel=['\"])|i" => '<a rel="nofollow"' 1276 ); 1277 $text = preg_replace(array_keys($r), array_values($r), $text); 1274 1278 $text = $wpdb->escape($text); 1275 1279 return $text; 1276 1280 } 1277 1281 1278 1282 /** 1279 * Callback to used to add rel=nofollow string to HTML A element.1280 *1281 * Will remove already existing rel="nofollow" and rel='nofollow' from the1282 * string to prevent from invalidating (X)HTML.1283 *1284 * @since 2.3.01285 *1286 * @param array $matches Single Match1287 * @return string HTML A Element with rel nofollow.1288 */1289 function wp_rel_nofollow_callback( $matches ) {1290 $text = $matches[1];1291 $text = str_replace(array(' rel="nofollow"', " rel='nofollow'"), '', $text);1292 return "<a $text rel=\"nofollow\">";1293 }1294 1295 1296 /**1297 1283 * Convert one smiley code to the icon graphic file equivalent. 1298 1284 * 1299 1285 * Looks up one smiley code in the $wpsmiliestrans global array and returns an