trmnl_preview 0.32.2 → 0.32.3

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: d9cf02342886e42a2a4b60b068657e4f58b446226febe78f8b8bcfa7758a8d54
4
- data.tar.gz: 3d63d0f368a43254e0fd6b1ae134559ec58be55c1179fbc33a603ebcfd561e05
3
+ metadata.gz: 55b67180ccff89b08d78384020c460edfdcafe59515cb23253e227cdc8f279cc
4
+ data.tar.gz: f95ebeec6e33edc5398bae038860acbe18dc4846d93676b98c7bb73a33800f24
5
5
  SHA512:
6
- metadata.gz: 5ab520c731381e951386bb168172c268a91732e94890e89a886dc685f5a980662b33ba6735138aa93374e96810dc1e405bb084b017debe6abb632dd72a9d152d
7
- data.tar.gz: 4033ff9382961fa5b6500e3eea051b42bef94c2c73afbedd89a2a6e2d06f3d690a3ddb37fc63df96d642912a463310fcf49e1f6766b21da90b7ee02e0bc099d5
6
+ metadata.gz: f8a5d6c769d20a3e7bef9b5c74f4d29ccad61f642210a0f7a4c2203393db36b950d34f56050b1b7e9b93d2293160d03a2f658b7be45951a63197eb400145d9af
7
+ data.tar.gz: 4e0b560990974bb719c0a99f441f6e85e8904e75e2172c3cf8ac230f4020260023ea481507f68946e1f876ada648fe76963360a877a611a3456ae454d27ce808
data/CHANGELOG.md CHANGED
@@ -1,6 +1,10 @@
1
1
 
2
2
  # Changelog
3
3
 
4
+ ## 0.32.3
5
+
6
+ - The poller refuses a polling URL line that TRMNL refuses, before it sends a request, and gives TRMNL's reason. A line that is not a complete http(s) URL, such as `h` or `//example.com`, has no host because a field it needs is empty, still has a `{{` or `{%`, or has a space or a non-ASCII host. Before, such a line could wait 10 seconds or fail with a connection error that did not say what was wrong.
7
+
4
8
  ## 0.32.2
5
9
 
6
10
  - The Docker image starts again. The 0.32.1 image kept the X display lock from its build in `/tmp`, so the display never started and every command, such as `trmnlp serve` or `trmnlp test`, waited forever. Running with `--tmpfs /tmp` worked around it. A stopped container started again had the same problem, and now clears the lock before the display starts. If the display still does not start, trmnlp stops within 10 seconds and prints why, where it used to wait forever.
@@ -37,6 +37,9 @@ module TRMNLP
37
37
  end
38
38
 
39
39
  def call(verb, url, headers:, body:)
40
+ refusal = refusal_reason(encoded(url))
41
+ return [nil, refusal] if refusal
42
+
40
43
  attempts = 0
41
44
  begin
42
45
  attempts += 1
@@ -82,6 +85,22 @@ module TRMNLP
82
85
  connection.get("#{url}#{url.include?('?') ? '&' : '?'}#{body}")
83
86
  end
84
87
 
88
+ # The same urls and words as TRMNL, which refuses these before it sends a request.
89
+ def refusal_reason(url)
90
+ return 'the url still contains an unrendered template tag' if url.match?(/\{\{|\{%/)
91
+
92
+ uri = URI.parse(url)
93
+ return 'the url is not a complete http(s) url' unless %w[http https].include?(uri.scheme&.downcase)
94
+
95
+ 'the url has no host, so a field it needs is probably empty' if uri.hostname.to_s.empty?
96
+ rescue URI::InvalidURIError
97
+ if url.match?(/[^\x00-\x7F]/)
98
+ 'the url host has non-ASCII characters, use its punycode (xn--) form'
99
+ else
100
+ 'the url has a character that must be percent-encoded, such as a space'
101
+ end
102
+ end
103
+
85
104
  def failure_reason(response)
86
105
  return 'the host replied 429 Too Many Requests' if response.status == 429
87
106
 
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module TRMNLP
4
- VERSION = '0.32.2'
4
+ VERSION = '0.32.3'
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: trmnl_preview
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.32.2
4
+ version: 0.32.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Rockwell Schrock