fugit 1.11.0 → 1.11.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 85c52688755255cf02f4dde422a66df260a9e9b1e13d7aebc08ff48e4c3fd158
4
- data.tar.gz: bf29e925bda6258e55e25208cfacff5ad82dfd9bd28683bb65c79ec95c5e37f1
3
+ metadata.gz: da93feee9bdfd44a793ce2b45b81109c0f7cd08ff9a930d15629a29c6a381e07
4
+ data.tar.gz: 32d9b447734805d3b58ae64c70a6699b931ef4fb4e6a76d8f279e66d4b5cb7df
5
5
  SHA512:
6
- metadata.gz: 6754049a51e4886bd806fe7d97ea64e5e0fc74851c579a7e8d46b7b42dedaa08aea04a9a8bec2f6c560df8a5cf57977dfdc6f8f33a73675dad885ad95b22c73f
7
- data.tar.gz: 03b507d208bee88cae70f7d85875e931600576a2e048fd8523d8c7ed58b8d34ea40423ff93be04cab42e73bb67ed5580e41e89e0bae1363c9a624a8865979d4f
6
+ metadata.gz: e7ac7afec4cfdcfdac22e5d2113892a0c7cb1f790d205bc32ecaea75c30f6ceb73af811824712c6781b480831f2a09479a6344af0d9b3c0ee92ae5cff7ef6c38
7
+ data.tar.gz: d87ecc490a49f19680891a82979903987843b5853ecfdc9ebee57d0b047fa4dffa96dfbbde43ef5d3011dbd07d492ac8f7a151fa6354478050c18efae9b911e4
data/CHANGELOG.md CHANGED
@@ -2,6 +2,11 @@
2
2
  # CHANGELOG.md
3
3
 
4
4
 
5
+ ## fugit 1.11.1 released 2024-08-15
6
+
7
+ * Prevent nat parsing chocking on long input (> 256 chars), gh-104
8
+
9
+
5
10
  ## fugit 1.11.0 released 2024-04-24
6
11
 
7
12
  * Revert gh-86 ban on `every 27 hours` / `* */27 * * *` for gh-103
data/CREDITS.md CHANGED
@@ -1,6 +1,7 @@
1
1
 
2
2
  # fugit credits
3
3
 
4
+ * https://github.com/personnumber3377, gh-104 Fugit.parse choke on long input
4
5
  * Michael Scrivo, https://github.com/mscrivo, gh-103
5
6
  * Benjamin Darcet, https://github.com/bdarcet gh-95 gh-96 et-orbi #rweek
6
7
  * https://github.com/franckduche gh-95 gh-96 et-orbi #rweek
data/README.md CHANGED
@@ -474,6 +474,8 @@ Fugit::Nat.parse('every day at 16:15 nada 18:30', multi: true)
474
474
 
475
475
  `multi: false` is the default behaviour, return a single `Fugit::Cron` instance or nil when it cannot parse.
476
476
 
477
+ Please note that "nat" input is limited to 256 characters (fugit 1.11.1).
478
+
477
479
  ### Nat Midnight
478
480
 
479
481
  `"Every day at midnight"` is supported, but `"Every monday at midnight"` will be interpreted (as of Fugit <= 1.4.x) as `"Every monday at 00:00"`. Sorry about that.
data/lib/fugit/cron.rb CHANGED
@@ -46,7 +46,20 @@ module Fugit
46
46
  def do_parse(s)
47
47
 
48
48
  parse(s) ||
49
- fail(ArgumentError.new("invalid cron string #{s.inspect}"))
49
+ fail(ArgumentError.new("invalid cron string #{trunc(s)}"))
50
+ end
51
+
52
+ protected
53
+
54
+ def trunc(s)
55
+
56
+ if s.is_a?(String)
57
+ r = s.length > 28 ? s[0, 28] + "... len #{s.length}" : s
58
+ r.inspect
59
+ else
60
+ r = s.inspect
61
+ r.length > 35 ? s[0, 35] + '...' : r
62
+ end
50
63
  end
51
64
  end
52
65
 
data/lib/fugit/nat.rb CHANGED
@@ -7,6 +7,8 @@ module Fugit
7
7
  #
8
8
  module Nat
9
9
 
10
+ MAX_INPUT_LENGTH = 256
11
+
10
12
  class << self
11
13
 
12
14
  def parse(s, opts={})
@@ -17,6 +19,16 @@ module Fugit
17
19
 
18
20
  s = s.strip
19
21
 
22
+ if s.length > MAX_INPUT_LENGTH
23
+
24
+ fail ArgumentError.new(
25
+ "input too long for a nat string, " +
26
+ "#{s.length} > #{MAX_INPUT_LENGTH}"
27
+ ) if opts[:do_parse]
28
+
29
+ return nil
30
+ end
31
+
20
32
  #p s; Raabro.pp(Parser.parse(s, debug: 3), colours: true)
21
33
  #(p s; Raabro.pp(Parser.parse(s, debug: 1), colours: true)) rescue nil
22
34
 
@@ -29,7 +41,7 @@ module Fugit
29
41
 
30
42
  def do_parse(s, opts={})
31
43
 
32
- parse(s, opts) ||
44
+ parse(s, opts.merge(do_parse: true)) ||
33
45
  fail(ArgumentError.new("could not parse a nat #{s.inspect}"))
34
46
  end
35
47
  end
data/lib/fugit/parse.rb CHANGED
@@ -20,10 +20,10 @@ module Fugit
20
20
 
21
21
  opts[:at] = opts[:in] if opts.has_key?(:in)
22
22
 
23
- (opts[:cron] != false && parse_cron(s)) ||
24
- (opts[:duration] != false && parse_duration(s)) ||
25
- (opts[:nat] != false && parse_nat(s, opts)) ||
26
- (opts[:at] != false && parse_at(s)) ||
23
+ (opts[:cron] != false && parse_cron(s)) || # 542ms 616ms
24
+ (opts[:duration] != false && parse_duration(s)) || # 645ms # 534ms
25
+ (opts[:nat] != false && parse_nat(s, opts)) || # 2s # 35s
26
+ (opts[:at] != false && parse_at(s)) || # 568ms 622ms
27
27
  nil
28
28
  end
29
29
 
data/lib/fugit.rb CHANGED
@@ -3,7 +3,7 @@
3
3
 
4
4
  module Fugit
5
5
 
6
- VERSION = '1.11.0'
6
+ VERSION = '1.11.1'
7
7
  end
8
8
 
9
9
  require 'time'
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fugit
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.11.0
4
+ version: 1.11.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - John Mettraux
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-04-24 00:00:00.000000000 Z
11
+ date: 2024-08-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: raabro