sequel 5.111.0 → 5.111.1

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: b1249ac10c8a72de802f1f7bfe0f976ffbd97e0e6c24e50c8c77d2f926abdb33
4
- data.tar.gz: 326ea06e85173c49f9bf2313ea29716e2f9e8dd9b9fb75216dbe9b372b930dfc
3
+ metadata.gz: aa663be1adaffaf8d34bdac717bd263b4f7ef5610b658371508540c959d84fb1
4
+ data.tar.gz: ca77ee5e8f322ce9d0d0c9a8036dcdc0f80818407ffcbb4c092ed3012088a157
5
5
  SHA512:
6
- metadata.gz: 7e3a88a89a58160a1a9a5698f0da9eb758e75b74547d40969e21e2198f74ee024e78a6c22765139aed1201285f8eb78c91794689b80d1ca6ac91269ce7f02e9b
7
- data.tar.gz: a2fc17d99e9b90db2ea1cd697e6e6b4af244c879acf5e64c2689c9a03da312b83f010d2903c39b2e3d8307dd3abb5e5ad45d3c6ebfff7480cc5431149e061d55
6
+ metadata.gz: edaaf3aac80e8724a786e394b07d2d7d9a3991bc931bdeb1a9fa40a2f6c4004e880cc641c01f06f9cac9666a14e7f29db5b14fe55f589108915c2245b3ddbcb0
7
+ data.tar.gz: 5856aaa2acec7e40ac76326d54fcb4e4452a34b577e10c4437db6a5a257ecc9e4d6cba25a81b9ae5c175ecdd39dc53219c2e6c45bea5215b705d629bba900fdf
@@ -730,6 +730,11 @@ module Sequel
730
730
  end
731
731
  end
732
732
 
733
+ # Oracle supports numeric literals such as 10e2 with full precision.
734
+ def supports_exponent_numeric_literals?
735
+ true
736
+ end
737
+
733
738
  # Oracle supports quoted function names.
734
739
  def supports_quoted_function_names?
735
740
  true
@@ -3143,6 +3143,11 @@ module Sequel
3143
3143
  db.server_version(@opts[:server])
3144
3144
  end
3145
3145
 
3146
+ # PostgreSQL supports numeric literals such as 10e2 with full precision.
3147
+ def supports_exponent_numeric_literals?
3148
+ true
3149
+ end
3150
+
3146
3151
  # PostgreSQL 9.4+ supports the FILTER clause for aggregate functions.
3147
3152
  def supports_filtered_aggregates?
3148
3153
  server_version >= 90400
@@ -595,7 +595,7 @@ module Sequel
595
595
 
596
596
  # Typecast the value to a BigDecimal
597
597
  def typecast_value_decimal(value)
598
- case value
598
+ v = case value
599
599
  when BigDecimal
600
600
  value
601
601
  when Numeric
@@ -605,6 +605,12 @@ module Sequel
605
605
  else
606
606
  raise InvalidValue, "invalid value for BigDecimal: #{value.inspect}"
607
607
  end
608
+
609
+ if v.exponent.abs > 1000
610
+ raise InvalidValue, "attempt to typecast to BigDecimal with too large exponent, likely attack"
611
+ end
612
+
613
+ v
608
614
  end
609
615
 
610
616
  # Typecast the value to a Float
@@ -622,6 +628,11 @@ module Sequel
622
628
  else
623
629
  Integer(value)
624
630
  end
631
+ when BigDecimal
632
+ if value.exponent.abs > 1000
633
+ raise InvalidValue, "attempt to typecast BigDecimal with too large exponent to Integer, likely attack"
634
+ end
635
+ Integer(value)
625
636
  else
626
637
  Integer(value)
627
638
  end
@@ -259,6 +259,13 @@ module Sequel
259
259
  supports_cte_in_subqueries?
260
260
  end
261
261
 
262
+ # Whether numeric literals such as 10e2 are supported with full precision.
263
+ # Most SQL databases either do not support such literals or treat them as
264
+ # decimal/float with limited precision.
265
+ def supports_exponent_numeric_literals?
266
+ false
267
+ end
268
+
262
269
  # Whether the dataset supports the FILTER clause for aggregate functions.
263
270
  # If not, support is emulated using CASE.
264
271
  def supports_filtered_aggregates?
@@ -1382,7 +1382,15 @@ module Sequel
1382
1382
 
1383
1383
  # SQL fragment for BigDecimal
1384
1384
  def literal_big_decimal(v)
1385
- d = v.to_s("F")
1385
+ if supports_exponent_numeric_literals?
1386
+ d = v.to_s
1387
+ else
1388
+ if v.exponent.abs > 1000
1389
+ raise InvalidValue, "attempt to literalize BigDecimal with too many digits, likely attack"
1390
+ end
1391
+ d = v.to_s("F")
1392
+ end
1393
+
1386
1394
  v.nan? || v.infinite? ? "'#{d}'" : d
1387
1395
  end
1388
1396
 
@@ -508,10 +508,8 @@ module Sequel
508
508
  ''
509
509
  when Time, Date
510
510
  ds.literal_date_or_time(k, true)
511
- when Integer, Float
511
+ when Integer, Float, BigDecimal
512
512
  k.to_s
513
- when BigDecimal
514
- k.to_s('F')
515
513
  when LiteralString
516
514
  k
517
515
  when String
@@ -10,7 +10,7 @@ module Sequel
10
10
 
11
11
  # The tiny version of Sequel. Usually 0, only bumped for bugfix
12
12
  # releases that fix regressions from previous versions.
13
- TINY = 0
13
+ TINY = 1
14
14
 
15
15
  # The version of Sequel you are using, as a string (e.g. "2.11.0")
16
16
  VERSION = [MAJOR, MINOR, TINY].join('.').freeze
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sequel
3
3
  version: !ruby/object:Gem::Version
4
- version: 5.111.0
4
+ version: 5.111.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jeremy Evans