mini_racer 0.17.0.pre10 → 0.17.0.pre12

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: f09948c878aaefbc5e47285a3ee17db34e00de5d72e441cbb4ef45dd15e45f06
4
- data.tar.gz: 95aa4a36b7612535524ff9ef6ca3116bde6dad9aa474c1c4b1af9427c0204969
3
+ metadata.gz: b2323caa96e4a3fae90be312b1d8788f2f2e663e586849ef03e97968c24c83a3
4
+ data.tar.gz: 5681ed08f41984354aa940919b295c0ff1d1fcfecc2a3a8e26b7f91874ae97d0
5
5
  SHA512:
6
- metadata.gz: 76a9a93bcb3bdfc0f7073e6a5501d8c96bd993bb85fe321ac54114154f015c0b0f1e2ba21067f79787831cff604f34e82079913b593dab559f4cb74e54781f17
7
- data.tar.gz: ea1da1f7e66915a147fe614cff9a6de80e2d5a2953eabb0de422c0ad2839db940cc9dbf2c5c642604b03fbd5ab71a6c0fd26e15abb38d4f4652273243a41221f
6
+ metadata.gz: 65e746097f2db9dbe8d36c95ab55d7ff0f5f6a35cfbe92b09e8ed0071e83471193555fa1e0c104880c054a0ad8e4c9807cc524922723c28a67d8029f8af6e265
7
+ data.tar.gz: 0c33c64e22d93312346d0edc6c4602a5bdb991b6c5077d8505d14b3b885469212f999e4a17ae5c32aa238416ebaab8354b0d3973b861e1f5923378776039a33d
data/CHANGELOG CHANGED
@@ -1,4 +1,10 @@
1
- - 0.17.0.pr10 - 20-01-2025
1
+ - 0.17.0.pre12 - 23-07-2025
2
+ - Corrected off-by-one error with object serialization - Ben Noordhuis
3
+
4
+ - 0.17.0.pre11 - 21-01-2025
5
+ - Corrected encoding bug with deserialization of strings - Ben Noordhuis
6
+
7
+ - 0.17.0.pre10 - 20-01-2025
2
8
  - Added back support for partially deserialized objects (objects that do not translate across boundaries are returned as Error properties) - Ben Noordhuis
3
9
 
4
10
  - 0.17.0.pre9 - 13-01-2025
@@ -339,13 +339,24 @@ static VALUE str_encode_bang(VALUE v)
339
339
 
340
340
  static void des_string8(void *arg, const uint8_t *s, size_t n)
341
341
  {
342
+ rb_encoding *e;
342
343
  DesCtx *c;
343
344
  VALUE v;
344
345
 
345
346
  c = arg;
346
- v = rb_enc_str_new((char *)s, n, rb_ascii8bit_encoding());
347
- if (c->transcode_latin1)
347
+ if (*c->err)
348
+ return;
349
+ if (c->transcode_latin1) {
350
+ e = rb_enc_find("ISO-8859-1"); // TODO cache?
351
+ if (!e) {
352
+ snprintf(c->err, sizeof(c->err), "no ISO-8859-1 encoding");
353
+ return;
354
+ }
355
+ v = rb_enc_str_new((char *)s, n, e);
348
356
  v = str_encode_bang(v); // cannot fail
357
+ } else {
358
+ v = rb_enc_str_new((char *)s, n, rb_ascii8bit_encoding());
359
+ }
349
360
  put(c, v);
350
361
  }
351
362
 
@@ -600,6 +611,13 @@ static int serialize1(Ser *s, VALUE refs, VALUE v)
600
611
  return 0;
601
612
  }
602
613
 
614
+ // don't mix with ser_array_begin/ser_object_begin because
615
+ // that will throw off the object reference count
616
+ static int serialize(Ser *s, VALUE v)
617
+ {
618
+ return serialize1(s, rb_hash_new(), v);
619
+ }
620
+
603
621
  static struct timespec deadline_ms(int ms)
604
622
  {
605
623
  static const int64_t ns_per_sec = 1000*1000*1000;
@@ -848,18 +866,11 @@ static void *rendezvous_callback(void *arg)
848
866
  goto fail;
849
867
  }
850
868
  ser_init1(&s, 'c'); // callback reply
851
- ser_array_begin(&s, 2);
852
- // either [result, undefined] or [undefined, err]
853
- if (exc)
854
- ser_undefined(&s);
855
- if (serialize1(&s, rb_hash_new(), r)) { // should not happen
869
+ if (serialize(&s, r)) { // should not happen
856
870
  c->exception = rb_exc_new_cstr(internal_error, s.err);
857
871
  ser_reset(&s);
858
872
  goto fail;
859
873
  }
860
- if (!exc)
861
- ser_undefined(&s);
862
- ser_array_end(&s, 2);
863
874
  out:
864
875
  buf_move(&s.b, a->req);
865
876
  return NULL;
@@ -1191,25 +1202,21 @@ static VALUE context_stop(VALUE self)
1191
1202
 
1192
1203
  static VALUE context_call(int argc, VALUE *argv, VALUE self)
1193
1204
  {
1194
- VALUE a, e, h;
1205
+ VALUE name, args;
1206
+ VALUE a, e;
1195
1207
  Context *c;
1196
- int i;
1197
1208
  Ser s;
1198
1209
 
1199
1210
  TypedData_Get_Struct(self, Context, &context_type, c);
1200
- rb_scan_args(argc, argv, "1*", &a, &e);
1201
- Check_Type(a, T_STRING);
1211
+ rb_scan_args(argc, argv, "1*", &name, &args);
1212
+ Check_Type(name, T_STRING);
1213
+ rb_ary_unshift(args, name);
1202
1214
  // request is (C)all, [name, args...] array
1203
1215
  ser_init1(&s, 'C');
1204
- ser_array_begin(&s, argc);
1205
- h = rb_hash_new();
1206
- for (i = 0; i < argc; i++) {
1207
- if (serialize1(&s, h, argv[i])) {
1208
- ser_reset(&s);
1209
- rb_raise(runtime_error, "Context.call: %s", s.err);
1210
- }
1216
+ if (serialize(&s, args)) {
1217
+ ser_reset(&s);
1218
+ rb_raise(runtime_error, "Context.call: %s", s.err);
1211
1219
  }
1212
- ser_array_end(&s, argc);
1213
1220
  // response is [result, err] array
1214
1221
  a = rendezvous(c, &s.b); // takes ownership of |s.b|
1215
1222
  e = rb_ary_pop(a);
@@ -378,18 +378,7 @@ void v8_api_callback(const v8::FunctionCallbackInfo<v8::Value>& info)
378
378
  des.ReadHeader(st.context).Check();
379
379
  v8::Local<v8::Value> result;
380
380
  if (!des.ReadValue(st.context).ToLocal(&result)) return; // exception pending
381
- v8::Local<v8::Object> response; // [result, err]
382
- if (!result->ToObject(st.context).ToLocal(&response)) return;
383
- v8::Local<v8::Value> err;
384
- if (!response->Get(st.context, 1).ToLocal(&err)) return;
385
- if (err->IsUndefined()) {
386
- if (!response->Get(st.context, 0).ToLocal(&result)) return;
387
- info.GetReturnValue().Set(result);
388
- } else {
389
- v8::Local<v8::String> message;
390
- if (!err->ToString(st.context).ToLocal(&message)) return;
391
- st.isolate->ThrowException(v8::Exception::Error(message));
392
- }
381
+ info.GetReturnValue().Set(result);
393
382
  }
394
383
 
395
384
  // response is err or empty string
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module MiniRacer
4
- VERSION = "0.17.0.pre10"
4
+ VERSION = "0.17.0.pre12"
5
5
  LIBV8_NODE_VERSION = "~> 22.7.0.4"
6
6
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mini_racer
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.17.0.pre10
4
+ version: 0.17.0.pre12
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sam Saffron
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2025-01-19 00:00:00.000000000 Z
11
+ date: 2025-01-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -123,9 +123,9 @@ licenses:
123
123
  - MIT
124
124
  metadata:
125
125
  bug_tracker_uri: https://github.com/discourse/mini_racer/issues
126
- changelog_uri: https://github.com/discourse/mini_racer/blob/v0.17.0.pre10/CHANGELOG
127
- documentation_uri: https://www.rubydoc.info/gems/mini_racer/0.17.0.pre10
128
- source_code_uri: https://github.com/discourse/mini_racer/tree/v0.17.0.pre10
126
+ changelog_uri: https://github.com/discourse/mini_racer/blob/v0.17.0.pre12/CHANGELOG
127
+ documentation_uri: https://www.rubydoc.info/gems/mini_racer/0.17.0.pre12
128
+ source_code_uri: https://github.com/discourse/mini_racer/tree/v0.17.0.pre12
129
129
  post_install_message:
130
130
  rdoc_options: []
131
131
  require_paths: