rmagick 7.1.3 → 7.1.4

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: 0d81d58d1022ce126e777f8fa23d3cd3ee634c3f1c9fd6518de50b3d6126b239
4
- data.tar.gz: 1cee4ad10699e4a2b4119c1e4ef86d3b206da05e1af830b450d43f8dcc7e1d62
3
+ metadata.gz: a5c3f56f5b39c2f505f37875134e7af86904393036c531e6074f2796939f204c
4
+ data.tar.gz: 3bf4833ad9aa56f93e1d2426bd6c72b95c54e0c2c8dcd2c4248f62635bf7606e
5
5
  SHA512:
6
- metadata.gz: 517f893ecbf2d2c34257ae10af315b7b5f9cf24104f3422c951334bb63a17ee23941198fa9e8d4404f6bd3deb75a4efbe9d707be6ada44108217c584ba793815
7
- data.tar.gz: 45f92c15dc8f1790de2a71949fb0c32fb496a7806266ff7ea9e0890e4da51e4dce4896b7ae09d0a4ec11a925b393f41fea34527cf21d45c54ad3917786ce2d6b
6
+ metadata.gz: ff12f7c040309d906c8ba517cc4a10c472019c0b99d718f470f24b804021dd2a431b4fd876a59e0c18eb8acbb8edac0eb2e15b68826a8ba11779e62e5894a202
7
+ data.tar.gz: 06dfb967d7de90cdc6791dcbb2e9fc6b5ece9ccef12e53b3588ea96c09960e28cd938b9f982654ccd95c6f765cd65a1fae179e3c230d14f4548511d851f36de8
data/CHANGELOG.md CHANGED
@@ -3,6 +3,22 @@
3
3
  All notable changes to this project are documented in this file.
4
4
  This project adheres to [Semantic Versioning](http://semver.org/).
5
5
 
6
+ ## RMagick 7.1.4
7
+
8
+ > [!IMPORTANT]
9
+ > Four kinds of input that used to be accepted now raise `ArgumentError`.
10
+ >
11
+ > Three of them were ways for a string RMagick documents as a value to be read back as part of an ImageMagick program: an opacity of `"1%\nimage Over 0,0 80,80 'secret.png'\n1%"`, a `Draw#pattern` name carrying the same payload, and a `Caption` property of `"@/etc/passwd"` arriving in the metadata of an uploaded image. ImageMagick executed the injected primitive, or read the named file and drew its contents into the returned image. `Image#dispatch` is the fourth: a `map` containing a NUL byte is now rejected rather than sized with the byte length while ImageMagick fills only what precedes the NUL.
12
+ >
13
+ > `Image#export_pixels_to_str` with `Magick::LongPixel` also returns half as many bytes on LP64, and `Image#import_pixels` takes a buffer of that size. RMagick reserved `sizeof(unsigned long)` per element while ImageMagick reads and writes `unsigned int`, so the second half of the string was never written and carried whatever the heap held. `Image#colormap` returned uninitialized memory the same way, as the previous colour of an entry it had just created.
14
+
15
+ Breaking Changes
16
+
17
+ * Reject an opacity percentage that is not a plain number from 0% to 100% (#1867)
18
+ * Restrict a Draw#pattern name to letters, digits, hyphen, period and underscore (#1869)
19
+ * Return LongPixel pixel data as unsigned int, without the uninitialized padding Image#export_pixels_to_str used to append (#1870)
20
+ * Reject a Caption property beginning with '@' in Image#polaroid instead of reading that file (#1871)
21
+
6
22
  ## RMagick 7.1.3
7
23
 
8
24
  Bug Fixes
@@ -3295,7 +3295,7 @@ Image_colormap(int argc, VALUE *argv, VALUE self)
3295
3295
  image->colormap = (PixelColor *)magick_safe_realloc(image->colormap, (idx+1), sizeof(PixelColor));
3296
3296
  }
3297
3297
 
3298
- for (i = image->colors; i < idx; i++)
3298
+ for (i = image->colors; i <= idx; i++)
3299
3299
  {
3300
3300
  image->colormap[i] = black;
3301
3301
  }
@@ -5758,7 +5758,8 @@ Image_dispatch(int argc, VALUE *argv, VALUE self)
5758
5758
  y = NUM2LONG(argv[1]);
5759
5759
  columns = NUM2ULONG(argv[2]);
5760
5760
  rows = NUM2ULONG(argv[3]);
5761
- map = rm_str2cstr(&argv[4], &mapL);
5761
+ map = StringValueCStr(argv[4]);
5762
+ mapL = strlen(map);
5762
5763
  if (argc == 6)
5763
5764
  {
5764
5765
  stg_type = RTEST(argv[5]) ? DoublePixel : QuantumPixel;
@@ -6903,7 +6904,7 @@ Image_export_pixels_to_str(int argc, VALUE *argv, VALUE self)
6903
6904
  sz = sizeof(float);
6904
6905
  break;
6905
6906
  case LongPixel:
6906
- sz = sizeof(unsigned long);
6907
+ sz = sizeof(unsigned int);
6907
6908
  break;
6908
6909
  case QuantumPixel:
6909
6910
  sz = sizeof(Quantum);
@@ -8174,7 +8175,7 @@ Image_import_pixels(int argc, VALUE *argv, VALUE self)
8174
8175
  type_sz = sizeof(unsigned short);
8175
8176
  break;
8176
8177
  case LongPixel:
8177
- type_sz = sizeof(unsigned long);
8178
+ type_sz = sizeof(unsigned int);
8178
8179
  break;
8179
8180
  case DoublePixel:
8180
8181
  type_sz = sizeof(double);
@@ -10867,7 +10868,8 @@ Image_pixel_interpolation_method_eq(VALUE self, VALUE method)
10867
10868
 
10868
10869
  /**
10869
10870
  * Produce an image that looks like a Polaroid instant picture. If the image has a "Caption"
10870
- * property, the value is used as a caption.
10871
+ * property, the value is used as a caption. A caption whose first non-blank character is '@'
10872
+ * is rejected because ImageMagick reads the caption from the file it names.
10871
10873
  *
10872
10874
  * The following annotate attributes control the label rendering:
10873
10875
  * align, decorate, density, encoding, fill, font, font_family, font_stretch, font_style,
@@ -10888,6 +10890,7 @@ Image_pixel_interpolation_method_eq(VALUE self, VALUE method)
10888
10890
  * @yieldparam opt [Magick::Image::PolaroidOptions]
10889
10891
  *
10890
10892
  * @return [Magick::Image] a new image
10893
+ * @raise [ArgumentError] if the "Caption" property begins with '@'
10891
10894
  */
10892
10895
  VALUE
10893
10896
  Image_polaroid(int argc, VALUE *argv, VALUE self)
@@ -10897,9 +10900,7 @@ Image_polaroid(int argc, VALUE *argv, VALUE self)
10897
10900
  double angle = -5.0;
10898
10901
  Draw *draw;
10899
10902
  ExceptionInfo *exception;
10900
- #if defined(IMAGEMAGICK_7)
10901
10903
  const char *caption;
10902
- #endif
10903
10904
 
10904
10905
  image = rm_check_destroyed(self);
10905
10906
 
@@ -10924,6 +10925,26 @@ Image_polaroid(int argc, VALUE *argv, VALUE self)
10924
10925
  exception = AcquireExceptionInfo();
10925
10926
  #if defined(IMAGEMAGICK_7)
10926
10927
  caption = GetImageProperty(clone, "Caption", exception);
10928
+ #else
10929
+ caption = GetImageProperty(clone, "Caption");
10930
+ #endif
10931
+ if (caption)
10932
+ {
10933
+ const char *p = caption;
10934
+
10935
+ while (isspace((int) ((unsigned char) *p)))
10936
+ {
10937
+ p++;
10938
+ }
10939
+ if (*p == '@')
10940
+ {
10941
+ DestroyImage(clone);
10942
+ DestroyExceptionInfo(exception);
10943
+ rb_raise(rb_eArgError, "the Caption property must not begin with '@'");
10944
+ }
10945
+ }
10946
+
10947
+ #if defined(IMAGEMAGICK_7)
10927
10948
  GVL_STRUCT_TYPE(PolaroidImage) args = { clone, draw->info, caption, angle, image->interpolate, exception };
10928
10949
  new_image = (Image *)CALL_FUNC_WITHOUT_GVL(GVL_FUNC(PolaroidImage), &args);
10929
10950
  #else
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Magick
4
- VERSION = '7.1.3'
4
+ VERSION = '7.1.4'
5
5
  MIN_RUBY_VERSION = '3.2.0'
6
6
  MIN_IM6_VERSION = '6.9.0'
7
7
  MIN_IM7_VERSION = '7.1.0'
@@ -228,7 +228,12 @@ module Magick
228
228
  end
229
229
 
230
230
  def to_opacity(opacity)
231
- return opacity if opacity.is_a?(String) && opacity.end_with?('%')
231
+ if opacity.is_a?(String) && opacity.end_with?('%')
232
+ percentage = /\A(\d*\.?\d+(?:[eE][-+]?\d+)?)%\z/.match(opacity)
233
+ Kernel.raise ArgumentError, 'opacity must be a percentage between 0% and 100%' unless percentage && Float(percentage[1]) <= 100
234
+
235
+ return opacity
236
+ end
232
237
 
233
238
  value = Float(opacity)
234
239
  Kernel.raise ArgumentError, 'opacity must be >= 0 and <= 1.0' if value < 0 || value > 1.0
@@ -448,14 +453,21 @@ module Magick
448
453
  # draw the pattern. Reference the pattern by using its name
449
454
  # as the argument to the 'fill' or 'stroke' methods
450
455
  def pattern(name, x, y, width, height)
456
+ name = to_string(name)
457
+ Kernel.raise ArgumentError, 'pattern name must consist of letters, digits, hyphen, period and underscore' unless /\A[\w.-]+\z/.match?(name)
458
+
459
+ viewport = sprintf('%g %g %g %g', x, y, width, height)
460
+
451
461
  push('defs')
452
- push("pattern #{to_string(name)} " + sprintf('%g %g %g %g', x, y, width, height))
462
+ push("pattern #{name} " + viewport)
453
463
  push('graphic-context')
454
- yield
455
- ensure
456
- pop('graphic-context')
457
- pop('pattern')
458
- pop('defs')
464
+ begin
465
+ yield
466
+ ensure
467
+ pop('graphic-context')
468
+ pop('pattern')
469
+ pop('defs')
470
+ end
459
471
  end
460
472
 
461
473
  # Set point to fill color.
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rmagick
3
3
  version: !ruby/object:Gem::Version
4
- version: 7.1.3
4
+ version: 7.1.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tim Hunter