1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33
|
Description: make slice RangeError rescue work on i386
Author: Simon Quigley <tsimonq2@debian.org>
Origin: vendor
Forwarded: not-needed
Last-Update: 2026-03-23
---
This patch header follows DEP-3: http://dep.debian.net/deps/dep3/
--- a/lib/liquid/standardfilters.rb
+++ b/lib/liquid/standardfilters.rb
@@ -11,6 +11,7 @@ module Liquid
MIN_I64 = -(1 << 63)
MAX_I64 = (1 << 63) - 1
I64_RANGE = MIN_I64..MAX_I64
+ I32_RANGE = -(1 << 31)..MAX_I32
private_constant :MIN_I64, :MAX_I64, :I64_RANGE
HTML_ESCAPE = {
@@ -215,10 +216,12 @@ module Liquid
end
rescue RangeError
if I64_RANGE.cover?(length) && I64_RANGE.cover?(offset)
- raise # unexpected error
+ offset = offset.clamp(I32_RANGE)
+ length = length.clamp(I32_RANGE)
+ else
+ offset = offset.clamp(I64_RANGE)
+ length = length.clamp(I64_RANGE)
end
- offset = offset.clamp(I64_RANGE)
- length = length.clamp(I64_RANGE)
retry
end
end
|