diff options
author | thomascube <thomas@roundcube.net> | 2011-02-09 10:51:50 +0000 |
---|---|---|
committer | thomascube <thomas@roundcube.net> | 2011-02-09 10:51:50 +0000 |
commit | b46e5b7407940499964d8a553c3eada05850f29d (patch) | |
tree | 882ffd6820097107176c1ba2e8341c0313f18ec2 /program/include/main.inc | |
parent | 98cb0f179206843ceaa87df6bfb3d1da045ed8ad (diff) |
Apply more bugfixes from trunk for 0.5.1
Diffstat (limited to 'program/include/main.inc')
-rw-r--r-- | program/include/main.inc | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/program/include/main.inc b/program/include/main.inc index b8d27d68c..f9cc4331b 100644 --- a/program/include/main.inc +++ b/program/include/main.inc @@ -1224,6 +1224,19 @@ function rcmail_remote_ip() /** + * Check whether the HTTP referer matches the current request + * + * @return boolean True if referer is the same host+path, false if not + */ +function rcube_check_referer() +{ + $uri = parse_url($_SERVER['REQUEST_URI']); + $referer = parse_url(rc_request_header('Referer')); + return $referer['host'] == rc_request_header('Host') && $referer['path'] == $uri['path']; +} + + +/** * @access private * @return mixed */ @@ -1863,6 +1876,39 @@ function check_email($email, $dns_check=true) return false; } +/* + * Idn_to_ascii wrapper. + * Intl/Idn modules version of this function doesn't work with e-mail address + */ +function rcube_idn_to_ascii($str) +{ + return rcube_idn_convert($str, true); +} + +/* + * Idn_to_ascii wrapper. + * Intl/Idn modules version of this function doesn't work with e-mail address + */ +function rcube_idn_to_utf8($str) +{ + return rcube_idn_convert($str, false); +} + +function rcube_idn_convert($input, $is_utf=false) +{ + if ($at = strpos($input, '@')) { + $user = substr($input, 0, $at); + $domain = substr($input, $at+1); + } + else { + $domain = $input; + } + + $domain = $is_utf ? idn_to_ascii($domain) : idn_to_utf8($domain); + + return $at ? $user . '@' . $domain : $domain; +} + /** * Helper class to turn relative urls into absolute ones |