Ruby: fixed encodings initialization.

The Ruby interpreter expects an explicit setlocale() call before initialization
to pick up character encodings in the "Encoding" class from the environment.

This closes #531 issue on GitHub.
This commit is contained in:
Valentin Bartenev
2021-03-15 15:03:32 +03:00
parent b0a1266835
commit 4c261a7ff8
2 changed files with 10 additions and 0 deletions

View File

@@ -37,6 +37,12 @@ Linux, and all uploaded certificate bundles were forgotten after restart.
</para> </para>
</change> </change>
<change type="bugfix">
<para>
the Ruby module didn't respect user locale for defaults in the Encoding class.
</para>
</change>
</changes> </changes>

View File

@@ -12,6 +12,8 @@
#include NXT_RUBY_MOUNTS_H #include NXT_RUBY_MOUNTS_H
#include <locale.h>
#define NXT_RUBY_RACK_API_VERSION_MAJOR 1 #define NXT_RUBY_RACK_API_VERSION_MAJOR 1
#define NXT_RUBY_RACK_API_VERSION_MINOR 3 #define NXT_RUBY_RACK_API_VERSION_MINOR 3
@@ -200,6 +202,8 @@ nxt_ruby_start(nxt_task_t *task, nxt_process_data_t *data)
nxt_ruby_threads = c->threads; nxt_ruby_threads = c->threads;
setlocale(LC_CTYPE, "");
RUBY_INIT_STACK RUBY_INIT_STACK
ruby_init(); ruby_init();
ruby_options(2, argv); ruby_options(2, argv);