From c9c4124f5ece17efd410d78ffecef92c02fe6845 Mon Sep 17 00:00:00 2001 From: Juanito Fatas Date: Sun, 2 Dec 2018 12:42:19 +0900 Subject: [PATCH] Only call deprecate_constant if available --- lib/loofah/helpers.rb | 4 +++- lib/loofah/html5/safelist.rb | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/lib/loofah/helpers.rb b/lib/loofah/helpers.rb index 17400b17..4cdfa3a3 100644 --- a/lib/loofah/helpers.rb +++ b/lib/loofah/helpers.rb @@ -95,7 +95,9 @@ def sanitize_css style_string, *args end WhiteListSanitizer = SafeListSanitizer - deprecate_constant :WhiteListSanitizer + if Object.respond_to?(:deprecate_constant) + deprecate_constant :WhiteListSanitizer + end end end end diff --git a/lib/loofah/html5/safelist.rb b/lib/loofah/html5/safelist.rb index 3144d352..558dea9c 100644 --- a/lib/loofah/html5/safelist.rb +++ b/lib/loofah/html5/safelist.rb @@ -787,7 +787,9 @@ module SafeList end WhiteList = SafeList - deprecate_constant :WhiteList + if Object.respond_to?(:deprecate_constant) + deprecate_constant :WhiteList + end ::Loofah::MetaHelpers.add_downcased_set_members_to_all_set_constants ::Loofah::HTML5::SafeList end