summaryrefslogtreecommitdiff
path: root/program/steps/utils
diff options
context:
space:
mode:
Diffstat (limited to 'program/steps/utils')
-rw-r--r--program/steps/utils/html2text.inc7
-rw-r--r--program/steps/utils/modcss.inc54
-rw-r--r--program/steps/utils/spell.inc3
-rw-r--r--program/steps/utils/text2html.inc33
4 files changed, 79 insertions, 18 deletions
diff --git a/program/steps/utils/html2text.inc b/program/steps/utils/html2text.inc
index c01443b22..f6e2bec4d 100644
--- a/program/steps/utils/html2text.inc
+++ b/program/steps/utils/html2text.inc
@@ -19,7 +19,12 @@
+-----------------------------------------------------------------------+
*/
-$html = $HTTP_RAW_POST_DATA;
+$html = stream_get_contents(fopen('php://input', 'r'));
+
+// strip slashes if magic_quotes enabled
+if (get_magic_quotes_gpc() || get_magic_quotes_runtime()) {
+ $html = stripslashes($html);
+}
// Replace emoticon images with its text representation
$html = $RCMAIL->replace_emoticons($html);
diff --git a/program/steps/utils/modcss.inc b/program/steps/utils/modcss.inc
index c8a7cb524..f3d8d897a 100644
--- a/program/steps/utils/modcss.inc
+++ b/program/steps/utils/modcss.inc
@@ -5,7 +5,7 @@
| program/steps/utils/modcss.inc |
| |
| This file is part of the Roundcube Webmail client |
- | Copyright (C) 2007-2012, The Roundcube Dev Team |
+ | Copyright (C) 2007-2014, The Roundcube Dev Team |
| |
| Licensed under the GNU General Public License version 3 or |
| any later version with exceptions for skins & plugins. |
@@ -33,27 +33,47 @@ if (!preg_match('~^(https?)://~i', $realurl, $matches)) {
exit("Invalid URL");
}
-if (!ini_get('allow_url_fopen')) {
+if (ini_get('allow_url_fopen')) {
+ $scheme = strtolower($matches[1]);
+ $options = array(
+ $scheme => array(
+ 'method' => 'GET',
+ 'timeout' => 15,
+ )
+ );
+
+ $context = stream_context_create($options);
+ $source = @file_get_contents($realurl, false, $context);
+
+ // php.net/manual/en/reserved.variables.httpresponseheader.php
+ $headers = implode("\n", (array) $http_response_header);
+}
+else if (function_exists('curl_init')) {
+ $curl = curl_init($realurl);
+ curl_setopt($curl, CURLOPT_TIMEOUT, 15);
+ curl_setopt($curl, CURLOPT_CONNECTTIMEOUT, 15);
+ curl_setopt($curl, CURLOPT_PROTOCOLS, CURLPROTO_HTTP | CURLPROTO_HTTPS);
+ curl_setopt($curl, CURLOPT_ENCODING, '');
+ curl_setopt($curl, CURLOPT_HEADER, true);
+ curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
+ $data = curl_exec($curl);
+
+ if ($data !== false) {
+ list($headers, $source) = explode("\r\n\r\n", $data, 2);
+ }
+ else {
+ $headers = false;
+ $source = false;
+ }
+}
+else {
header('HTTP/1.1 403 Forbidden');
exit("HTTP connections disabled");
}
-$scheme = strtolower($matches[1]);
-$options = array(
- $scheme => array(
- 'method' => 'GET',
- 'timeout' => 15,
- )
-);
-
-$context = stream_context_create($options);
-$source = @file_get_contents($realurl, false, $context);
-
-// php.net/manual/en/reserved.variables.httpresponseheader.php
-$headers = implode("\n", (array)$http_response_header);
-$ctype = '~Content-Type:\s+text/(css|plain)~i';
+$ctype_regexp = '~Content-Type:\s+text/(css|plain)~i';
-if ($source !== false && preg_match($ctype, $headers)) {
+if ($source !== false && preg_match($ctype_regexp, $headers)) {
header('Content-Type: text/css');
echo rcube_utils::mod_css_styles($source, preg_replace('/[^a-z0-9]/i', '', $_GET['_c']));
exit;
diff --git a/program/steps/utils/spell.inc b/program/steps/utils/spell.inc
index c8807e32f..696fa6005 100644
--- a/program/steps/utils/spell.inc
+++ b/program/steps/utils/spell.inc
@@ -37,6 +37,9 @@ if ($learn_word) {
$spellchecker->add_word($data);
$result = '<?xml version="1.0" encoding="'.RCUBE_CHARSET.'"?><learnwordresult></learnwordresult>';
}
+else if (empty($data)) {
+ $result = '<?xml version="1.0" encoding="'.RCUBE_CHARSET.'"?><spellresult charschecked="0"></spellresult>';
+}
else {
$spellchecker->check($data);
$result = $spellchecker->get_xml();
diff --git a/program/steps/utils/text2html.inc b/program/steps/utils/text2html.inc
new file mode 100644
index 000000000..56d15fa19
--- /dev/null
+++ b/program/steps/utils/text2html.inc
@@ -0,0 +1,33 @@
+<?php
+
+/*
+ +-----------------------------------------------------------------------+
+ | program/steps/utils/text2html.inc |
+ | |
+ | This file is part of the Roundcube Webmail client |
+ | Copyright (C) 2005-2014, The Roundcube Dev Team |
+ | |
+ | Licensed under the GNU General Public License version 3 or |
+ | any later version with exceptions for skins & plugins. |
+ | See the README file for a full license statement. |
+ | |
+ | PURPOSE: |
+ | Convert plain text to HTML |
+ | |
+ +-----------------------------------------------------------------------+
+ | Author: Thomas Bruederli <roundcube@gmail.com> |
+ +-----------------------------------------------------------------------+
+*/
+
+$text = stream_get_contents(fopen('php://input', 'r'));
+
+// strip slashes if magic_quotes enabled
+if (get_magic_quotes_gpc() || get_magic_quotes_runtime()) {
+ $html = stripslashes($html);
+}
+
+$converter = new rcube_text2html($text, false, array('wrap' => true));
+
+header('Content-Type: text/html; charset=' . RCUBE_CHARSET);
+print $converter->get_html();
+exit;