summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorsvncommit <devs@roundcube.net>2007-06-08 23:47:57 +0000
committersvncommit <devs@roundcube.net>2007-06-08 23:47:57 +0000
commit8094288d237a2503de6f97956b5558b28c4db56b (patch)
tree8b1b8f1a5740b57a845c650dda301839ae36e522
parent570f0bb4a609b04dab58407a642922dfdf715bd5 (diff)
fixed html2text in editor
-rw-r--r--bin/html2text.php9
-rw-r--r--index.php16
-rw-r--r--program/js/editor.js3
3 files changed, 9 insertions, 19 deletions
diff --git a/bin/html2text.php b/bin/html2text.php
index e0e2679f7..7f74ac622 100644
--- a/bin/html2text.php
+++ b/bin/html2text.php
@@ -8,9 +8,14 @@ $converter = new html2text($htmlText);
header('Content-Type: text/plain; charset=UTF-8');
$plaintext = $converter->get_text();
-if (function_exists('html_entity_decode'))
+$phpver = explode('.', phpversion());
+$vernum = $phpver[0] . $phpver[1] . $phpver[2];
+
+# html_entity_decode doesn't handle UTF character sets in PHP 4.x
+
+if (($vernum >= 500) && function_exists('html_entity_decode'))
print html_entity_decode($plaintext, ENT_COMPAT, 'UTF-8');
else
print $plaintext;
-?> \ No newline at end of file
+?>
diff --git a/index.php b/index.php
index bde223497..60474998f 100644
--- a/index.php
+++ b/index.php
@@ -82,7 +82,6 @@ require_once('include/rcube_imap.inc');
require_once('include/bugs.inc');
require_once('include/main.inc');
require_once('include/cache.inc');
-require_once('lib/html2text.inc');
require_once('PEAR.php');
@@ -146,21 +145,6 @@ if ($_action=='error' && !empty($_GET['_code']))
raise_error(array('code' => hexdec($_GET['_code'])), FALSE, TRUE);
-// handle HTML->text conversion
-if ($_action=='html2text')
-{
- $htmlText = $HTTP_RAW_POST_DATA;
- $converter = new html2text($htmlText);
-
- // TODO possibly replace with rcube_remote_response()
- header('Content-Type: text/plain');
- $plaintext = $converter->get_text();
- print $plaintext;
-
- exit;
-}
-
-
// try to log in
if ($_action=='login' && $_task=='mail')
{
diff --git a/program/js/editor.js b/program/js/editor.js
index 3a191b594..df68cdd41 100644
--- a/program/js/editor.js
+++ b/program/js/editor.js
@@ -99,7 +99,8 @@ function rcmail_html2plain(htmlText)
http_request.onerror = function(o) { rcmail_handle_toggle_error(o); };
http_request.oncomplete = function(o) { rcmail_set_text_value(o); };
- var url=rcmail.env.comm_path+'&_action=html2text';
+ var url = rcmail.env.bin_path+'html2text.php';
+ console.log('HTTP request: ' + url);
http_request.POST(url, htmlText, 'application/octet-stream');
}