Skip to content
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

Use (safe) markdown instead of raw text in render_multi_or_match_content #32521

Merged
merged 18 commits into from
Jan 15, 2020

Conversation

Hamms
Copy link
Contributor

@Hamms Hamms commented Dec 20, 2019

Description

To prevent HTML injection in translations.

Also update the content of those DSL levels currently using HTML to use Markdown. Note: a couple of the updated levels do have minor visual changes. Those changes have all been approved by the relevant curriculum team member.

Uses the new inline markdown renderer added in #32573

Also see this gsheet for a breakdown of which DSL levels are using what kind of supported content (text, image, iframe, blockly, html) in the affected fields.

Links

Reviewer Checklist:

  • Tests provide adequate coverage
  • Code is well-commented
  • New features are translatable or updates will not break translations
  • Relevant documentation has been added or updated
  • User impact is well-understood and desirable
  • Pull Request is labeled appropriately
  • Follow-up work items (including potential tech debt) are tracked and linked

Hamms added a commit that referenced this pull request Jan 8, 2020
Similar to #32531; will be used by #32521 to upgrade the `render_multi_or_match_content` helper, which usually renders into headers or labels and therefore needs inline rendering support.
@Hamms Hamms changed the title Markdownify dsls Use (safe) markdown instead of raw text in render_multi_or_match_content Jan 13, 2020
@Hamms Hamms marked this pull request as ready for review January 13, 2020 23:35
@@ -672,7 +673,8 @@ def render_multi_or_match_content(text)
return match_answer_as_embedded_blockly(path) if File.extname(path).ends_with? '_blocks'
return match_answer_as_iframe(path, width) if File.extname(path) == '.level'

text
@markdown_renderer ||= Redcarpet::Markdown.new(Redcarpet::Render::Inline)
@markdown_renderer.render(text).html_safe
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks like it will create a new markdown renderer for each instance of each class which includes this module and calls this method, including once for each multi or match script level object. Perhaps it would be better to store it on @@markdown_renderer, so that it only gets instantiated once for each class which includes this module and calls this method?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oh, good catch!

wrong "rocket-height(seconds) = seconds \* 48"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove extraneous \? if it is needed, I'm curious why its not also needed on line 12.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

weird; I'm not sure why this got added, given that it is indeed not needed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants