- π―π΅Japan tyler36 Osaka
I just came across with today with Drupal
10.1
and following this guide: Drupal 10: Creating A Notification System Using The Message And ECA Modules
Every time I enter the following message text:
<p> <a href="[message:field_message_comment_ref:entity:entity:url:path]">[message:field_message_comment_ref:entity:author:name] commented on [message:field_message_comment_ref:entity:entity:title]</a> </p>
The href gets broken and it becomes:
<p> <a href="path]">[message:field_message_comment_ref:entity:author:name] commented on [message:field_message_comment_ref:entity:entity:title]</a> </p>
- π©πͺGermany a.dmitriiev
a.dmitriiev β made their first commit to this issueβs fork.
- Merge request !58Issue #3268243: Rendering of texts in MessageTemplate:getText() potentially breaks tokens β (Open) created by a.dmitriiev
- π©πͺGermany a.dmitriiev
I suggest to slightly modify the order of message text processing. The
getText
method in MessageTemplate entity class should not be rendered yet, but instead thegetText
method in Message entity class should do this, and the token processing should be done before the rendering. This way there will be also additional filter processing of the values that were replaced by tokens, for example if message template uses basic text format, but the token might have some not-allowed html tag or something, this way if rendering happens after the token replace, this makes the solution more secure (I might be wrong of course).To not break all other contrib modules (like message_ui), that rely on certain structure to be returned by
getText
method of MessageTemplate entity class, I have added one more optional parameter to it, that indicates whether it is a preview of text or real processing withing Message entity class.I hope this change will not break the tests.
- π©πͺGermany a.dmitriiev
Of course the tests are failing :( now the built render array of a message has a Markup object and not the array anymore.