From 71c59ea0327f99bd2635308057d92bc4d1f12721 Mon Sep 17 00:00:00 2001 From: Stan Hu Date: Sun, 14 Mar 2021 11:21:00 -0700 Subject: [PATCH] Restrict Rouge formatters to values in Rouge::Formatters namespace ff0218aefcf00cd5a389e17e075d36cd46d011e2 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 ``` --- lib/kramdown/converter/syntax_highlighter/rouge.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/kramdown/converter/syntax_highlighter/rouge.rb b/lib/kramdown/converter/syntax_highlighter/rouge.rb index c799526c..ed6a4f83 100644 --- a/lib/kramdown/converter/syntax_highlighter/rouge.rb +++ b/lib/kramdown/converter/syntax_highlighter/rouge.rb @@ -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