Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion ext/java/org/jruby/ext/cgi/escape/CGIEscape.java
Original file line number Diff line number Diff line change
Expand Up @@ -339,7 +339,7 @@ static IRubyObject optimized_escape(Ruby runtime, RubyString str, boolean escape

int buf = 0;
Ruby runtime = context.runtime;

for (i = 0; i < len; ++i) {
int c = cstrBytes[cstr + i] & 0xFF;
int clen = 0;
Expand Down
4 changes: 2 additions & 2 deletions lib/cgi/core.rb
Original file line number Diff line number Diff line change
Expand Up @@ -629,8 +629,8 @@ def read_from_cmdline
string = unless ARGV.empty?
ARGV.join(' ')
else
if STDIN.tty?
STDERR.print(
if stdinput.tty?
$stderr.print(
%|(offline mode: enter name=value pairs on standard input)\n|
)
end
Expand Down
4 changes: 2 additions & 2 deletions test/cgi/test_cgi_escape.rb
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,7 @@ def setup
remove_method :escapeHTML
alias _unescapeHTML unescapeHTML
remove_method :unescapeHTML
end if defined?(CGI::EscapeExt)
end if defined?(CGI::EscapeExt) and CGI::EscapeExt.method_defined?(:escapeHTML)
end

def teardown
Expand All @@ -309,7 +309,7 @@ def teardown
remove_method :_escapeHTML
alias unescapeHTML _unescapeHTML
remove_method :_unescapeHTML
end if defined?(CGI::EscapeExt)
end if defined?(CGI::EscapeExt) and CGI::EscapeExt.method_defined?(:_escapeHTML)
end

include CGIEscapeTest::UnescapeHTMLTests
Expand Down
22 changes: 11 additions & 11 deletions test/cgi/test_cgi_new.rb
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ def test_tag_maker_functionality
'html4Fr' => '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Frameset//EN" "http://www.w3.org/TR/html4/frameset.dtd">',
'html5' => '<!DOCTYPE HTML>'
}

html_versions.each do |version, expected_doctype|
cgi = CGI.new(tag_maker: version)
assert_respond_to(cgi, :doctype, "HTML generation methods should be loaded for #{version}")
Expand All @@ -80,11 +80,11 @@ def test_string_tag_maker_equivalent

cgi1 = CGI.new('html5')
cgi2 = CGI.new(tag_maker: 'html5')

# Both should have HTML generation methods loaded
assert_respond_to(cgi1, :doctype)
assert_respond_to(cgi2, :doctype)

# Both should produce the same doctype
assert_equal(cgi1.doctype, cgi2.doctype)
assert_equal('<!DOCTYPE HTML>', cgi1.doctype)
Expand All @@ -96,13 +96,13 @@ def test_offline_mode
ENV.delete('QUERY_STRING')
ENV.delete('SERVER_SOFTWARE')
ENV.delete('SERVER_PROTOCOL')

# Create test input
test_input = "name=value&test=123"
$stdin = StringIO.new(test_input)

cgi = CGI.new

# In offline mode, it should read from stdin
assert_equal("value", cgi['name'])
assert_equal("123", cgi['test'])
Expand Down Expand Up @@ -145,7 +145,7 @@ def test_object_structure
)

cgi = CGI.new

# Test documented instance variables and methods exist
assert_kind_of(Hash, cgi.cookies)
assert_kind_of(Hash, cgi.params)
Expand Down Expand Up @@ -182,7 +182,7 @@ def test_encoding_error_block_handling
'REQUEST_METHOD' => 'POST',
'CONTENT_TYPE' => 'application/x-www-form-urlencoded',
'CONTENT_LENGTH' => test_input.length.to_s,
'SERVER_SOFTWARE' => 'Apache 2.2.0',
'SERVER_SOFTWARE' => 'Apache 2.2.0',
'SERVER_PROTOCOL' => 'HTTP/1.1',
)

Expand All @@ -208,7 +208,7 @@ def test_class_vs_instance_charset

# Class default should be UTF-8
assert_equal(Encoding::UTF_8, CGI.accept_charset)

# Instance with no option should use class default internally
cgi = CGI.new
assert_equal(Encoding::UTF_8, cgi.instance_variable_get(:@accept_charset))
Expand Down Expand Up @@ -257,10 +257,10 @@ def test_option_assignment
assert_equal('EUC-JP', cgi1.instance_variable_get(:@accept_charset))
assert_equal(512 * 1024, cgi2.instance_variable_get(:@max_multipart_length))
assert_respond_to(cgi3, :doctype)

assert_equal('ISO-8859-1', cgi4.instance_variable_get(:@accept_charset))
assert_equal(256 * 1024, cgi4.instance_variable_get(:@max_multipart_length))
assert_respond_to(cgi4, :doctype)
assert_equal('<!DOCTYPE HTML>', cgi4.doctype)
end
end
end