Skip to content

Replace Java environment vars with fully-native #6248

@headius

Description

@headius

While investigating the test failures reported in #6171 I ran across a CGI test that fails:

req = Net::HTTP::Get.new("/webrick.cgi/%A4%DB%A4%B2/%A4%DB%A4%B2")
http.request(req){|res|
  assert_equal("/\xA4\xDB\xA4\xB2/\xA4\xDB\xA4\xB2", res.body, log.call)
}

This URL gets parsed out and passed to a CGI subprocess via an environment variable, but because it does not decode as valid UTF-8 it's not possible for JRuby to either set or get that variable without mangling the original bytes.

Unfortunately the root cause is Java's own System.getenv, which promises a map from String to String and therefore must be able to decode environment variables to characters.

The only way we can support this use case, where differently-encoded text or undecodable bytes are stored in an environment variable, would be to bypass System.getenv and go straight to the native getenv function. Since this is a much larger fix than I wanted to attempt for #6171, I'm filing this issue and will expand WEBrick's own test exclusion to also exclude the "java" platform.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions