Skip to content

Commit

Permalink
Fix (double) quotes in the HTML output
Browse files Browse the repository at this point in the history
(Double) quotes could not be parsed in JavaScript/JSON, as the strings were ending prematurely resulting in parse errors
  • Loading branch information
veger committed Apr 4, 2015
1 parent 164fc4d commit be0b7a7
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion lib/ruby-bbcode/templates/bbcode_errors_template.rb
Expand Up @@ -59,7 +59,9 @@ def get_between
end

def self.error_attribute(errors)
"data-bbcode-errors='#{JSON.fast_generate(errors)}'"
# Escape (double) quotes so the JSON can be generated properly (and parsed properly by JavaScript)
escapedErrors = errors.map { |error| error.gsub("\"",""").gsub("'", "'")}
"data-bbcode-errors='#{JSON.fast_generate(escapedErrors)}'"
end
end
end

0 comments on commit be0b7a7

Please sign in to comment.