aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--lib/cgi/core.rb9
-rw-r--r--lib/cgi/util.rb6
-rw-r--r--test/cgi/test_cgi_util.rb4
3 files changed, 17 insertions, 2 deletions
diff --git a/lib/cgi/core.rb b/lib/cgi/core.rb
index fd9c41aa31..5895cf8541 100644
--- a/lib/cgi/core.rb
+++ b/lib/cgi/core.rb
@@ -4,6 +4,13 @@
# generating HTTP responses.
#++
class CGI
+ unless const_defined?(:Util)
+ module Util
+ @@accept_charset = "UTF-8" # :nodoc:
+ end
+ include Util
+ extend Util
+ end
$CGI_ENV = ENV # for FCGI support
@@ -734,7 +741,7 @@ class CGI
#
# CGI.accept_charset = "EUC-JP"
#
- @@accept_charset="UTF-8"
+ @@accept_charset="UTF-8" if false # needed for rdoc?
# Return the accept character set for all new CGI instances.
def self.accept_charset
diff --git a/lib/cgi/util.rb b/lib/cgi/util.rb
index d765fd73e6..18eaf44375 100644
--- a/lib/cgi/util.rb
+++ b/lib/cgi/util.rb
@@ -1,5 +1,9 @@
# frozen_string_literal: true
-class CGI; module Util; end; extend Util; end
+class CGI
+ module Util; end
+ include Util
+ extend Util
+end
module CGI::Util
@@accept_charset="UTF-8" unless defined?(@@accept_charset)
# URL-encode a string.
diff --git a/test/cgi/test_cgi_util.rb b/test/cgi/test_cgi_util.rb
index 9c9067a488..02558892b2 100644
--- a/test/cgi/test_cgi_util.rb
+++ b/test/cgi/test_cgi_util.rb
@@ -60,6 +60,10 @@ class CGIUtilTest < Test::Unit::TestCase
return unless defined?(::Encoding)
assert_raise(TypeError) {CGI.unescape('', nil)}
+ assert_separately(%w[-rcgi/util], "#{<<-"begin;"}\n#{<<-"end;"}")
+ begin;
+ assert_equal("", CGI.unescape(''))
+ end;
end
def test_cgi_pretty