-
Notifications
You must be signed in to change notification settings - Fork 109
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
fixes for downloads #1170
fixes for downloads #1170
Conversation
updated security check
@@ -43,7 +43,7 @@ | |||
<% blank = answer.present? ? answer.text.gsub(/<\/?p>/, '').gsub(/<br\s?\/?>/, '').chomp.blank? : true %> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
using answer.is_valid? would help to simplify this context. we should address this later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ah yeah. adding the code to ignore the html to this is_valid would be better.
Could probably make use of the Nokogiri gem to load the answer.text value into html and then do a check on that html object's .text()
to make sure its ignoring all markup when checking the answer. Instead of doing the regex matches
@@ -43,7 +43,7 @@ | |||
<% blank = answer.present? ? answer.text.gsub(/<\/?p>/, '').gsub(/<br\s?\/?>/, '').chomp.blank? : true %> | |||
<% if blank && @show_unanswered %> | |||
<p><%= _('Question not answered.') -%></p> | |||
<% else %> | |||
<% elsif !blank %> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
rails helper method .present? would be a clearer solution instead of the baked variable blank we have defined above...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it would be but I'm seeing a lot of <p></p>
stored in the DB. I'm thinking that this is happening when the user blanks out the answer. That value always equates to present? true
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yep! If that's the case we should look at tinymce to clear out everything so the answer text becomes '' and therefore .present? is false
addresses issues in #1127
.joins(:answers)
since we cannot guarantee that the plan has at least one answer before user tries to download.