Changeset 1121 for trunk/smf/Sources/Subs.php
- Timestamp:
- 03/29/10 15:37:29 (2 years ago)
- File:
-
- 1 edited
-
trunk/smf/Sources/Subs.php (modified) (15 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/smf/Sources/Subs.php
r1048 r1121 6 6 * Open-Source Project Inspired by Zef Hemel (zef@zefhemel.com) * 7 7 * =============================================================================== * 8 * Software Version: SMF 1.1. 9*8 * Software Version: SMF 1.1.11 * 9 9 * Software by: Simple Machines (http://www.simplemachines.org) * 10 10 * Copyright 2006-2009 by: Simple Machines LLC (http://www.simplemachines.org) * … … 1235 1235 'type' => 'unparsed_content', 1236 1236 'content' => '<a href="$1" target="_blank">$1</a>', 1237 'validate' => create_function('&$tag, &$data, $disabled', '$data = strtr($data, array(\'<br />\' => \'\'));'), 1237 'validate' => create_function('&$tag, &$data, $disabled', ' 1238 $data = strtr($data, array(\'<br />\' => \'\')); 1239 if (strpos($data, \'ftp://\') !== 0 && strpos($data, \'ftps://\') !== 0) 1240 $data = \'ftp://\' . $data; 1241 '), 1238 1242 ), 1239 1243 array( … … 1242 1246 'before' => '<a href="$1" target="_blank">', 1243 1247 'after' => '</a>', 1248 'validate' => create_function('&$tag, &$data, $disabled', ' 1249 if (strpos($data, \'ftp://\') !== 0 && strpos($data, \'ftps://\') !== 0) 1250 $data = \'ftp://\' . $data; 1251 '), 1244 1252 'disallow_children' => array('email', 'ftp', 'url', 'iurl'), 1245 1253 'disabled_after' => ' ($1)', … … 1259 1267 'validate' => create_function('&$tag, &$data, $disabled', ' 1260 1268 if (isset($disabled[\'url\'])) 1261 $tag[\'content\'] = \'$1\';'), 1269 $tag[\'content\'] = \'$1\'; 1270 elseif (strpos($data[0], \'http://\') !== 0 && strpos($data[0], \'https://\') !== 0) 1271 $data[0] = \'http://\' . $data[0]; 1272 '), 1262 1273 'disabled_content' => '<a href="$1" target="_blank">$1</a>', 1263 1274 ), … … 1296 1307 ), 1297 1308 'content' => '<img src="$1" alt="{alt}"{width}{height} border="0" />', 1298 'validate' => create_function('&$tag, &$data, $disabled', '$data = strtr($data, array(\'<br />\' => \'\'));'), 1309 'validate' => create_function('&$tag, &$data, $disabled', ' 1310 $data = strtr($data, array(\'<br />\' => \'\')); 1311 if (strpos($data, \'http://\') !== 0 && strpos($data, \'https://\') !== 0) 1312 $data = \'http://\' . $data; 1313 '), 1299 1314 'disabled_content' => '($1)', 1300 1315 ), … … 1303 1318 'type' => 'unparsed_content', 1304 1319 'content' => '<img src="$1" alt="" border="0" />', 1305 'validate' => create_function('&$tag, &$data, $disabled', '$data = strtr($data, array(\'<br />\' => \'\'));'), 1320 'validate' => create_function('&$tag, &$data, $disabled', ' 1321 $data = strtr($data, array(\'<br />\' => \'\')); 1322 if (strpos($data, \'http://\') !== 0 && strpos($data, \'https://\') !== 0) 1323 $data = \'http://\' . $data; 1324 '), 1306 1325 'disabled_content' => '($1)', 1307 1326 ), … … 1315 1334 'type' => 'unparsed_content', 1316 1335 'content' => '<a href="$1">$1</a>', 1317 'validate' => create_function('&$tag, &$data, $disabled', '$data = strtr($data, array(\'<br />\' => \'\'));'), 1336 'validate' => create_function('&$tag, &$data, $disabled', ' 1337 $data = strtr($data, array(\'<br />\' => \'\')); 1338 if (strpos($data, \'http://\') !== 0 && strpos($data, \'https://\') !== 0) 1339 $data = \'http://\' . $data; 1340 '), 1318 1341 ), 1319 1342 array( … … 1324 1347 'validate' => create_function('&$tag, &$data, $disabled', ' 1325 1348 if (substr($data, 0, 1) == \'#\') 1326 $data = \'#post_\' . substr($data, 1);'), 1349 $data = \'#post_\' . substr($data, 1); 1350 elseif (strpos($data, \'http://\') !== 0 && strpos($data, \'https://\') !== 0) 1351 $data = \'http://\' . $data; 1352 '), 1327 1353 'disallow_children' => array('email', 'ftp', 'url', 'iurl'), 1328 1354 'disabled_after' => ' ($1)', … … 1577 1603 'type' => 'unparsed_content', 1578 1604 'content' => '<a href="$1" target="_blank">$1</a>', 1579 'validate' => create_function('&$tag, &$data, $disabled', '$data = strtr($data, array(\'<br />\' => \'\'));'), 1605 'validate' => create_function('&$tag, &$data, $disabled', ' 1606 $data = strtr($data, array(\'<br />\' => \'\')); 1607 if (strpos($data, \'http://\') !== 0 && strpos($data, \'https://\') !== 0) 1608 $data = \'http://\' . $data; 1609 '), 1580 1610 ), 1581 1611 array( … … 1584 1614 'before' => '<a href="$1" target="_blank">', 1585 1615 'after' => '</a>', 1616 'validate' => create_function('&$tag, &$data, $disabled', ' 1617 if (strpos($data, \'http://\') !== 0 && strpos($data, \'https://\') !== 0) 1618 $data = \'http://\' . $data; 1619 '), 1586 1620 'disallow_children' => array('email', 'ftp', 'url', 'iurl'), 1587 1621 'disabled_after' => ' ($1)', … … 1719 1753 if (!empty($modSettings['enablePostHTML']) && strpos($data, '<') !== false) 1720 1754 { 1721 $data = preg_replace('~<a\s+href=( ?:")?((?:http://|ftp://|https://|ftps://|mailto:).+?)(?:")?>~i', '[url=$1]', $data);1755 $data = preg_replace('~<a\s+href=((?:")?)((?:https?://|ftps?://|mailto:)\S+?)\\1>~i', '[url=$2]', $data); 1722 1756 $data = preg_replace('~</a>~i', '[/url]', $data); 1723 1757 … … 1739 1773 1740 1774 // Do <img ... /> - with security... action= -> action-. 1741 preg_match_all('~<img\s+src=( ?:")?((?:http://|ftp://|https://|ftps://).+?)(?:")?(?:\s+alt=(?:")?(.*?)(?:")?)?(?:\s?/)?>~i', $data, $matches, PREG_PATTERN_ORDER);1775 preg_match_all('~<img\s+src=((?:")?)((?:https?://|ftps?://)\S+?)\\1(?:\s+alt=(".*?"|\S*?))?(?:\s?/)?>~i', $data, $matches, PREG_PATTERN_ORDER); 1742 1776 if (!empty($matches[0])) 1743 1777 { 1744 1778 $replaces = array(); 1745 foreach ($matches[ 1] as $match => $imgtag)1779 foreach ($matches[2] as $match => $imgtag) 1746 1780 { 1747 // No alt? 1748 if (!isset($matches[2][$match])) 1749 $matches[2][$match] = ''; 1781 $alt = empty($matches[3][$match]) ? '' : ' alt=' . preg_replace('~^"|"$~', '', $matches[3][$match]); 1750 1782 1751 1783 // Remove action= from the URL - no funny business, now. … … 1771 1803 1772 1804 // Set the new image tag. 1773 $replaces[$matches[0][$match]] = ' <img src="' . $imgtag . '" width="' . $width . '" height="' . $height . '" alt="' . $matches[2][$match] . '" border="0" />';1805 $replaces[$matches[0][$match]] = '[img width=' . $width . ' height=' . $height . $alt . ']' . $imgtag . '[/img]'; 1774 1806 } 1775 1807 else 1776 $replaces[$matches[0][$match]] = ' <img src="' . $imgtag . '" alt="' . $matches[2][$match] . '" border="0" />';1808 $replaces[$matches[0][$match]] = '[img' . $alt . ']' . $imgtag . '[/img]'; 1777 1809 } 1778 1810 … … 1806 1838 // Switch out quotes really quick because they can cause problems. 1807 1839 $data = strtr($data, array(''' => '\'', ' ' => $context['utf8'] ? "\xC2\xA0" : "\xA0", '"' => '>">', '"' => '<"<', '<' => '<lt<')); 1808 $data = preg_replace(array('~(?<=[\s>\.(;\'"]|^)((?:http|https|ftp|ftps)://[\w\-_%@:|]+(?:\.[\w\-_%]+)*(?::\d+)?(?:/[\w\-_\~%\.@,\?&;=#+:\'\\\\]*|[\(\{][\w\-_\~%\.@,\?&;=#(){}+:\'\\\\]*)*[/\w\-_\~%@\?;=#}\\\\])~i', '~(?<=[\s>(\'<]|^)(www(?:\.[\w\-_]+)+(?::\d+)?(?:/[\w\-_\~%\.@,\?&;=#+:\'\\\\]*|[\(\{][\w\-_\~%\.@,\?&;=#(){}+:\'\\\\]*)*[/\w\-_\~%@\?;=#}\\\\])~i'), array('[url]$1[/url]', '[url=http://$1]$1[/url]'), $data); 1840 1841 // Only do this if the preg survives. 1842 if (is_string($result = preg_replace(array( 1843 '~(?<=[\s>\.(;\'"]|^)((?:http|https|ftp|ftps)://[\w\-_%@:|]+(?:\.[\w\-_%]+)*(?::\d+)?(?:/[\w\-_\~%\.@,\?&;=#(){}+:\'\\\\]*)*[/\w\-_\~%@\?;=#}\\\\])~i', 1844 '~(?<=[\s>(\'<]|^)(www(?:\.[\w\-_]+)+(?::\d+)?(?:/[\w\-_\~%\.@,\?&;=#(){}+:\'\\\\]*)*[/\w\-_\~%@\?;=#}\\\\])~i' 1845 ), array( 1846 '[url]$1[/url]', 1847 '[url=http://$1]$1[/url]' 1848 ), $data))) 1849 $data = $result; 1850 1809 1851 $data = strtr($data, array('\'' => ''', $context['utf8'] ? "\xC2\xA0" : "\xA0" => ' ', '>">' => '"', '<"<' => '"', '<lt<' => '<')); 1810 1852 } … … 2437 2479 $smileyfromcache[] = '/(?<=[>:\?\.\s' . $non_breaking_space . '[\]()*\\\;]|^)(' . preg_quote($smileysfrom[$i], '/') . '|' . preg_quote(htmlspecialchars($smileysfrom[$i], ENT_QUOTES), '/') . ')(?=[^[:alpha:]0-9]|$)/' . ($context['utf8'] ? 'u' : ''); 2438 2480 // Escape a bunch of smiley-related characters in the description so it doesn't get a double dose :P. 2439 $smileytocache[] = '<img src="' . $modSettings['smileys_url'] . '/' . $user_info['smiley_set'] . '/' . $smileysto[$i]. '" alt="' . strtr(htmlspecialchars($smileysdescs[$i]), array(':' => ':', '(' => '(', ')' => ')', '$' => '$', '[' => '[')) . '" border="0" />';2481 $smileytocache[] = '<img src="' . htmlspecialchars($modSettings['smileys_url'] . '/' . $user_info['smiley_set'] . '/' . $smileysto[$i]) . '" alt="' . strtr(htmlspecialchars($smileysdescs[$i]), array(':' => ':', '(' => '(', ')' => ')', '$' => '$', '[' => '[')) . '" border="0" />'; 2440 2482 } 2441 2483 }
Note: See TracChangeset
for help on using the changeset viewer.
![[infoarena] development](/chrome/site/logo.png)