Sha256: 421657e3e146b8422943c5a830f65600095a1cf6217c737166308f7b23f070aa
Contents?: true
Size: 1.38 KB
Versions: 2
Compression:
Stored size: 1.38 KB
Contents
/* Copyright (c) 2020 Contrast Security, Inc. See * https://www.contrastsecurity.com/enduser-terms-0317a for more details. */ #include "cs__assess_array.h" #include "../cs__common/cs__common.h" #include <ruby.h> /* * If String#split is called without an argument, it defaults to use `$;`. * We have to make this patch in C so as not to change that value. * -HM */ static VALUE contrast_assess_array_join(const int argc, const VALUE *argv, const VALUE ary) { VALUE sep, result; /* We need to figure out the separator the join method actually used. */ /* First, check if one was provided. */ rb_scan_args(argc, argv, "01", &sep); /* Second, check to see if `$;` is set*/ if (NIL_P(sep)) { sep = rb_output_fs; } /* Finally, default to empty String. Implicit since nil.to_s is ''*/ result = rb_funcall2(ary, rb_sym_assess_array_join, argc, argv); result = rb_funcall(ary, rb_sym_assess_track_array_join, 2, sep, result); return result; } void Init_cs__assess_array(void) { rb_sym_assess_array_join = rb_intern("cs__patched_join"); rb_sym_assess_track_array_join = rb_intern("__cs_track_join"); VALUE array_class = rb_define_class("Array", rb_cObject); contrast_alias_method(array_class, "cs__patched_join", "join"); rb_define_method(array_class, "join", contrast_assess_array_join, -1); }
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
contrast-agent-3.8.5 | ext/cs__assess_array/cs__assess_array.c |
contrast-agent-3.8.4 | ext/cs__assess_array/cs__assess_array.c |