Closed (fixed)
Project:
Private Message
Version:
3.0.x-dev
Component:
Code
Priority:
Major
Category:
Bug report
Assigned:
Unassigned
Reporter:
Created:
9 May 2018 at 14:17 UTC
Updated:
3 Dec 2024 at 08:54 UTC
Jump to comment: Most recent, Most recent file


Comments
Comment #2
opdaviesComment #3
opdaviesComment #4
vandna b commented#3 patch is successfully applied
Comment #5
keshavv commentedComment #6
vandna b commentedComment #8
jaypanComment #10
zenimagine commentedThe last dev does not correct the problem
Comment #11
jaypanComment #12
maaty388 commentedI can confirm that this is working on the latest dev version...
Can you please provide more information?
Comment #13
zenimagine commentedYes I installed "Private Message Nodejs". The problem is only with the messages sent and received by the administrator.
Comment #14
zenimagine commentedI changed the text format in the template message but there are still the div tags that appear
Comment #15
PhilippVerpoortI can confirm that I've been experiencing the same issue with what's currently the latest release (8.x-2.0-beta15), and it doesn't seem to matter whether messages are sent from the an admin account or not.
Comment #16
opdaviesI've been still seeing issues when trying to send emails as HTML, where the paragraph tags are appearing from the WYSIWYG field when the token content is replaced.
Attached is a patch that fixes it for me on the 8.x-1.x branch, though I think there's probably a more Drupal-y way to do the last section rather than using
str_replaceandhtmlentities. I don't see theprivate_message_mailfunction in the 8.x-2.x branch at all.Comment #17
zenimagine commentedHas anyone found a solution for version 2?
Comment #18
zenimagine commented@Jaypan Hi, do you have a patch to fix this tag problem ?
See my 3 screenshots
Comment #19
zenimagine commenteddelete
Comment #20
zenimagine commentedThe problem is corrected for me.
Just do not check the "Respect provided e-mail format." box in the "SwiftMailer" module.
Comment #21
alternativo commentedHello,
same problem for me (html tags on mail object), solved modifying message_notify.module - function message_notify_mail ()
and message_notify\src\Plugin\Notifier\Email.php customizing the function deliver().
if someone needs details, ask
thanks,
bye
Comment #22
abdelrahman amer commented@alternativo
can u please give me more details about this solution
Comment #23
abdelrahman amer commentedComment #24
alternativo commentedHi Abdelrahman Amer,
this what I did:
message_notify.module:
function message_notify_mail($key, &$message, $params) {
$options = array(
'langcode' => $message['langcode'],
);
switch ($key) {
case 'newmess':
$message['headers'] = $params['headers'];
$message['from'] = \Drupal::config('system.site')->get('mail');
$message['subject'] = t('@messsender has sent you a message!', array('@messsender' => $params['mess_sender']), $options);
$message['body'][] = '
' .
t('Hello @userreceiver, @messsender your text!
', array('@userreceiver' => $params['user_receiver'], '@userpath' => $params['user_path'], '@messsender' => $params['mess_sender']), $options).
'';
break;
}
}
And Email.php in deliver() function:
$mailManager = \Drupal::service('plugin.manager.mail');
$module = 'message_notify';
$key = 'newmess';
$to = $mail;
$params['headers']['MIME-Version'] = '1.0';
$params['headers']['Content-Type'] = 'text/html; charset=UTF-8';
$params['headers']['Content-Transfer-Encoding'] = '8Bit';
$currentusername = \Drupal::currentUser()->getUsername();
$params['user_path'] = 'http://yoursite.com' . \Drupal::currentUser()->id();
$params['mess_sender'] = $currentusername;
$receiver = user_load_by_mail($mail);
$params['user_receiver'] = $receiver->getUsername();
$langcode = $receiver->getPreferredLangcode();
$send = true;
$result = $mailManager->mail($module, $key, $to, $langcode, $params, NULL, $send);
Hope it helps
Comment #25
sagesolutions commentedI tried patch #23, but
<p> <p>results in I've added different solution that instead of showing the html, it renders the html.
https://drupal.stackexchange.com/questions/222201/how-can-i-display-toke... for reference.
Comment #26
hoporr commentedWe had the same problem as #25, and the patch in #25 worked well, for version 3.0.0-beta.
Comment #27
sagesolutions commentedComment #28
jphelan commentedPatch #25 works for me on 3.0.1.
Comment #29
dxvargas commentedI have a question about the patch #25 and the usage of
Drupal\Core\Render\Markup::create. Is it safe?I'm afraid we are marking the message sent by the user as safe and sending it as is in the email.
Can someone please confirm or rebut this?
Comment #30
jaypanI don't think it is. From the Markup documentation:
Comment #32
jphelan commentedYeah, I think you guys are right, I think we need to use Xss::filter() on it. I've created a new patch to allow only a few safe HTML tags.
Comment #33
herved commentedCan't we simply use
$private_message->get('message')->processed?This uses
\Drupal\text\TextProcessed::getValueand returns aFilteredMarkupwhich would align with the filter format. It would align with the filter used whileXss::filtermay filter way more than expected.Comment #34
claudiu.cristeaAgree with #33
Comment #35
zaryab_drupal commentedComment #36
claudiu.cristeaWe need a test to prove that text from email is not HTML-encoded. Also, please use the MR, with patches there's no test run
Comment #39
claudiu.cristeaFixing credits an hiding patches.
Comment #41
claudiu.cristeaThank you all
Comment #42
herved commented