-
Notifications
You must be signed in to change notification settings - Fork 1.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Email not displaying/being parsed properly #6713
Comments
I have a similar problem, the first line of the message is missing. I'm also using the current git master (4d1b3e2). The message is something like:
If we decode the base64, the message is something like:
I found that
|
The @MrBMT's sample contains |
It's a $html = "<html>Hello, This is a test.<br />Does it work this time?</html>";
$html = "Hello, This is a test.<br />Does it work this time?"; it still thinks it is in // This is sort of a last-ditch attempt to correct for cases where no head/body
// elements are provided.
if ($this->insertMode <= static::IM_BEFORE_HEAD && 'head' !== $name && 'html' !== $name) {
$this->insertMode = static::IM_IN_BODY;
} so, |
I agree that we need a better fix. I created a ticket for Mastermind Masterminds/html5-php#166. |
Implemented workaround. Fixed. |
@alecpl I updated to the latest git master and it still wasn't being processed correctly. I ran what was being passed through to the fix_html5() function through htmlspecialchars() then var_dumped the result, which turned out to be: So for some reason, roundcube is adding In addition, the In order to fix things, I had to amend the function as follows: /**
* Cleanup and workarounds on input to Masterminds/HTML5
*/
protected function fix_html5($html)
{
$html = str_replace('<head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /></head>', "", $html);
// HTML5 requires <head> or <body> (#6713)
// https://github.com/Masterminds/html5-php/issues/166
if (!preg_match('/<(head|body)/i', $html)) {
$pos = stripos($html, '<html');
if ($pos === false) {
$html = '<html><body>' . $html;
}
else {
$pos = strpos($html, '>', $pos);
$html = substr_replace($html, '<body>', $pos+1, 0);
}
}
return $html;
} I haven't had a chance this evening to look in to where the Thanks for looking in to this! |
I forgot we add that meta tag in another place. Should be fixed now. |
@alecpl unfortunately, this fix doesn't solve my issue. My problematic message skips the added Não, não, era mesmo só para lhe dizer que foi um erro meu. O problema do overfitting mantém-se.
<div class="quote" style="line-height: 1.5"><br>
<br>-------- Mensagem original --------
<br>Assunto: Re: Re.: Gráficos
<br>De: (...)
<br>Para: (...)<br><br>
<blockquote (...)>
<html>
<head><meta charset="UTF-8" /></head>
<body dir="auto">Mas acha que deveríamos repensar e (...) For my case, the following PHPUnit test case must work: $html = 'First line<br /><html><body>Second line';
$washed = $washer->wash($html);
$this->assertContains('First line', $washed); While it's not fixed, i must patch the diff --git a/program/lib/Roundcube/rcube_washtml.php b/program/lib/Roundcube/rcube_washtml.php
index 8e4edde..459d9cf 100644
--- a/program/lib/Roundcube/rcube_washtml.php
+++ b/program/lib/Roundcube/rcube_washtml.php
@@ -783,6 +783,14 @@ class rcube_washtml
*/
protected function fix_html5($html)
{
+ // work only with the first part of the message, before any HTML tag
+ if ($pos = strpos($html, '<')) {
+ $html_after = substr($html, $pos);
+ $html = substr($html, 0, $pos);
+ } else {
+ $html_after = '';
+ }
+
// HTML5 requires <head> or <body> (#6713)
// https://github.com/Masterminds/html5-php/issues/166
if (!preg_match('/<(head|body)/i', $html)) {
@@ -797,6 +805,8 @@ class rcube_washtml
}
}
+ $html .= $html_after;
+
return $html;
} |
Problem with this sample is that it is not really a valid HTML. DOMDocument-based code didn't indeed skip that text, so maybe we should support that case too. What a mess. |
Fixed. |
Note: This is with the current git master (4d1b3e2) being used.
I sent an email to myself today from another system, however the text displayed via Roundcube is incorrect - the first line is completely missing.
The message sent was:
However it displays via Roundcube:
As shown in this screenshot:
Viewing the HTML being produced, it is completely ignoring the first line of the email:
<div id="messagebody"><div class="message-htmlpart" id="message-htmlpart1"><div class="rcmBody"><!-- html ignored --><!-- head ignored --><!-- meta ignored --><!-- html ignored --><br />Does it work this time?</div></div>
For your reference, an anonymised version of the raw message source is below:
The text was updated successfully, but these errors were encountered: