Skip to content

Commit

Permalink
Restrict Rouge formatters to values in Rouge::Formatters namespace
Browse files Browse the repository at this point in the history
ff0218a added support for specifying
custom Rouge formatters, but it did not actually enforce this constraint.
For example, this is valid:

```ruby
Rouge::Formatters.const_get('CSV')
=> CSV
```

Adding the `false` parameter to `const_get` prevents this:

```ruby
Rouge::Formatters.const_get('CSV', false)
NameError: uninitialized constant Rouge::Formatters::CSV
```
  • Loading branch information
stanhu committed Mar 14, 2021
1 parent 9cb5afc commit 71c59ea
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion lib/kramdown/converter/syntax_highlighter/rouge.rb
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ def self.formatter_class(opts = {})
when Class
formatter
when /\A[[:upper:]][[:alnum:]_]*\z/
::Rouge::Formatters.const_get(formatter)
::Rouge::Formatters.const_get(formatter, false)
else
# Available in Rouge 2.0 or later
::Rouge::Formatters::HTMLLegacy
Expand Down

0 comments on commit 71c59ea

Please sign in to comment.