We’ve upgraded from 3.0.3 to 3.1.7 on one of our test systems, but are having an issue with the MOTD when using markdown_erb in /etc/ood/config/apps/dashboard/env
MOTD_PATH='/etc/motd.portal'
MOTD_FORMAT='markdown_erb'
MOTD_TITLE='Announcements and Links'
And re-ran update_ood_portal with no luck. If I switch MOTD_FORMAT to straight markdown, then I get
So, the issue seems to be specific to markdown_erb and rendering HTML, but I don’t see anything else in the MOTD section on the 3.1 manual that would explain what’s going on.
Any idea’s why the MOTD HTML output isn’t actually rendering as HTML in my configuration and what I need to do to correct it?
You can find this config motd_render_html at the bottom of this page. We added this as a safety check for folks that don’t want potentially unsafe html (like script tags) being shown.
Oh sorry! Must not have read it entirely. You shouldn’t need to update_ood_portal or bounce httpd, but you do need to Restart Web Server in the help menu to pick up new configurations.
Sure, it’s just a shell script we wrote that prints out the date of the monthly system PM for that host. It gets run via /etc/profile.d on SSH login:
$ /bin/next_pm
Next preventative maintenance for atmos6 will be on Saturday, August 17, 2024.
This system will be UNAVAILABLE that day between 5:30am and 7:00am.
Or for Open OnDemand MOTD, it does the same but includes some HTML tags to make it look correctly formatted in a web browser:
$ /bin/next_pm --portal
Next preventative maintenance for atmos6 will be on <b>Saturday, August 17, 2024</b>.<br><br>This system will be <b>UNAVAILABLE</b> that day between 5:30am and 7:00am.
This is what it looks like on the 3.0.3 systems we haven’t updated:
Wanted to add, yes, I believe it’s a bug. I modified /var/www/ood/apps/sys/dashboard/app/models/motd_formatter/markdown_erb.rb to include the same safe_content code that markdown.rb has:
module MotdFormatter
# Utility class for rendering Markdown MOTD files after ERB rendering them.
class MarkdownErb
attr_reader :content, :title
def initialize(motd_file)
motd_file ||= MotdFile.new unless motd_file
@title = motd_file.title
@content = safe_content(OodAppkit.markdown.render(ERB.new(motd_file.content).result))
end
def to_partial_path
"dashboard/motd_markdown"
end
def safe_content(content)
if Configuration.motd_render_html?
content.html_safe
else
sanitize(content)
end
end
end
end
And things are now correctly rendering on 3.1.7 using markdown_erb: