Redmine Issues with HTML Formatting
By : Josh -
I recently had an issue with a client where we had deployed Redmine with an add-on plugin (CKEditor) that displayed all updates to issues as HTML. This resulted in all new issues and content being created with HTML tags but existing/previous content was not and it looked like a big glob on the page. To resolve this, I created a simple script that would connect to the database and update the journals table notes column to add basic paragraph and line breaks to format the output in a clean manner.
I’ll note that I did try the rake task that comes with ckeditor to convert all notes to texttile formatting but it also formatted all of the new content that was already correct so I had to rollback (via database restore).
The script is a simple redmine loop that loops over the results of a SQL query like the following that looks for notes without formatting and longer than 10 characters:
@raw_journal_results = @raw_journal_client.query(" SELECT id ,journalized_id ,notes FROM #{@db_schema}.journals WHERE notes NOT LIKE '<%' AND LENGTH(notes) > 10 ").each do |row| ...
Then update the notes to replace all newlines with an HTML break, and add a paragraph markup to the start and end of the notes.
I then set this to run every few minutes as we also use the email fetch feature to pull in email updates and they are not formatted either. This script, when run successfully once, only takes <1 minute to run so it's easy on the system and keeps things formatted properly for new issues.
Do you know how I can keep the easyredmine from stripping html tags when updating a ticket through email? I think this is the code that is causing it. I’ve commented out some of the code and its helpd bring back some of the html but not all of it.
Hi Kandace,
Did you manage to get this resolved?
If you didn’t get it resolved – can you confirm that the email being sent does not have a plain text part that is being inserted? Some email clients send both HTML and plain text and render HTML if the client supports it and plain text if not. It looks like the function “stripped_plain_text_body” returns this plain text part if it exists, else it tries to create it from the HTML message format.
Thanks,
Josh
Hey Josh,
Actually no I did not get this resolved. Some of my emails do have plain text like a description that are wrapped in tags. But it seems to be stripping all html properties, elements and inserting its own elements such as class=”msoNormalTable”. I thought that the ckeditor might be doing this or maybe the easyhelpdesk plugin, but I can’t seem to pinpoint it. In all my settings I have it set to html. I would so love your help on solving this!
its updating the journal desc like this in the db:
asdf
From:
esc…
Sorry forgot to use markup
“`
asdf
From: user@hostname.com [mailto:user@hostname.com]
Sent: Wednesday, November 29, 2017 1:08 PM
To: Firstname Lastname
Subject: [Sales > Website Contact Requests] updated – #53557 – Contact Form – FROM: CustomerFirst CustomerLast – DEPARTMENT: Consumer Support (Contact Customer)
“`
Sorry forgot to use markup
“`
asdf
From: user@hostname.com [mailto:user@hostname.com]
Sent: Wednesday, November 29, 2017 1:08 PM
To: Firstname Lastname
“`
Hi Kandace,
Can you send me your redmine install details, plugins and versions, redmine version, etc..? Maybe email them to me vs post here to keep them somewhat private ( josh itsecureadmin com.
Under Redmine -> Administration -> Information
Thanks,
Josh
Hy, i have a similar issue with the html tags from ckeditor,
on the search result page, to much html tags shift the usability for reading the text.
and more
Do you know the place for change the Regexp escape,
Thank you, and best regards