agoo 2.15.2 → 2.15.4

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: ad246b7aa0e634eff81c6c9bdec4d3567115a3beb8b6c237e25f87215fc2dbe3
4
- data.tar.gz: 03b6217fd351024938607dd036dcfd437a0dd967b22eca2b51aa0ed8a041d969
3
+ metadata.gz: f4f9e647ee51b00410d85de35a301d61dd6795175a2add858d29b4777d5889fb
4
+ data.tar.gz: 707f1a41efc1f051c15f661774063b45e48f989377d14c9c5cf59579fb962f68
5
5
  SHA512:
6
- metadata.gz: a244ea77e0f13688e2e6237c31eb320af4c0eeb9780f6023ef6337db7f64839ce543a27d5890155fb0908f0ce6567733b750be0d7b7c4de246430c54a736b6f4
7
- data.tar.gz: abf7f274c15852b21b64ac6018b03264d08968902b9ad71d4f56d84a5ea34cf018b5e26daf6bde44f7f748da57a889c373435658cfb085ff537f3a683433c6d3
6
+ metadata.gz: 896d35cc2800c9096192cf86d8595c1bf01f60f4b6509283d059911dbbc29ba5062fd03c38356d3bd29860d71a2f050d7c6ac5d12f011de699f8e5a9c33615af
7
+ data.tar.gz: 140970f8d879fd73773688f3d1cb0b526834abe20077aa6b5e5b32e3c82c83359f74b425fc130df0ed64ac8727f41e74a69222d26eab9940d94640f91874dc92
data/CHANGELOG.md CHANGED
@@ -2,6 +2,19 @@
2
2
 
3
3
  All changes to the Agoo gem are documented here. Releases follow semantic versioning.
4
4
 
5
+ ## [2.15.4] - 2023-03-05
6
+
7
+ ### Fixed
8
+
9
+ - Ruby 3.2.1 and MacOS didn't work well together with libssl missing
10
+ some symbols. Included libcrypt to fix that.
11
+
12
+ ## [2.15.3] - 2022-09-23
13
+
14
+ ### Fixed
15
+
16
+ - Asset names with spaces or special characters are now loaded correctly.
17
+
5
18
  ## [2.15.2] - 2022-06-21
6
19
 
7
20
  ### Fixed
data/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # [![{}j](misc/agoo_128.svg)](http://www.ohler.com/agoo) Agoo
2
2
 
3
- [![Build Status](https://img.shields.io/github/workflow/status/ohler55/agoo/CI?logo=github)](https://github.com/ohler55/agoo/actions/workflows/CI.yml)
3
+ [![Build Status](https://img.shields.io/github/actions/workflow/status/ohler55/agoo/CI.yml?logo=github&branch=develop)](https://github.com/ohler55/agoo/actions/workflows/CI.yml)
4
4
  [![Gem Version](https://badge.fury.io/rb/agoo.svg)](https://badge.fury.io/rb/agoo)
5
5
  ![Gem](https://img.shields.io/gem/dt/agoo.svg) [![TideLift](https://tidelift.com/badges/github/ohler55/agoo)](https://tidelift.com/subscription/pkg/rubygems-agoo?utm_source=rubygems-agoo&utm_medium=referral&utm_campaign=readme)
6
6
 
data/ext/agoo/extconf.rb CHANGED
@@ -23,6 +23,7 @@ have_header('stdatomic.h')
23
23
  have_header('sys/epoll.h')
24
24
  have_header('openssl/ssl.h')
25
25
  have_library('ssl')
26
+ have_library('crypto')
26
27
 
27
28
  create_makefile(File.join(extension_name, extension_name))
28
29
 
data/ext/agoo/page.c CHANGED
@@ -110,6 +110,16 @@ static struct _mime mime_map[] = {
110
110
 
111
111
  static const char page_fmt[] = "HTTP/1.1 200 OK\r\nContent-Type: %s\r\nContent-Length: %ld\r\n\r\n";
112
112
  static const char page_min_fmt[] = "HTTP/1.1 200 OK\r\nContent-Length: %ld\r\n";
113
+ // 0123456789abcdef0123456789abcdef
114
+ static const char hex_map[] = "\
115
+ ................................\
116
+ ................\x00\x01\x02\x03\x04\x05\x06\x07\x08\x09......\
117
+ .\x0a\x0b\x0c\x0d\x0e\x0f.........................\
118
+ .\x0a\x0b\x0c\x0d\x0e\x0f.........................\
119
+ ................................\
120
+ ................................\
121
+ ................................\
122
+ ................................";
113
123
 
114
124
  static struct _cache cache = {
115
125
  .buckets = {0},
@@ -120,29 +130,35 @@ static struct _cache cache = {
120
130
  .head_rules = NULL,
121
131
  };
122
132
 
133
+ static char
134
+ parse_percent_seq(const char *seq) {
135
+ const char *end = seq + 2;
136
+ uint8_t h;
137
+ uint8_t b = 0;
138
+
139
+ for (; seq < end; seq++) {
140
+ if (16 < (h = hex_map[(uint8_t)*seq])) {
141
+ return '?';
142
+ }
143
+ b = (b << 4) | h;
144
+ }
145
+ return (char)b;
146
+ }
147
+
123
148
  static uint64_t
124
149
  calc_hash(const char *key, int *lenp) {
125
150
  int len = 0;
126
151
  int klen = *lenp;
127
152
  uint64_t h = 0;
128
- bool special = false;
129
153
  const uint8_t *k = (const uint8_t*)key;
130
154
 
131
155
  for (; len < klen; k++) {
132
- // narrow to most used range of 0x4D (77) in size
133
- if (*k < 0x2D || 0x7A < *k) {
134
- special = true;
135
- }
136
156
  // fast, just spread it out
137
157
  h = 77 * h + (*k - 0x2D);
138
158
  len++;
139
159
  }
160
+ *lenp = len;
140
161
 
141
- if (special) {
142
- *lenp = -len;
143
- } else {
144
- *lenp = len;
145
- }
146
162
  return h;
147
163
  }
148
164
 
@@ -790,9 +806,25 @@ agoo_page_get(agooErr err, const char *path, int plen, const char *root) {
790
806
  if ('/' != *root && '/' != *(s - 1) && '/' != *path) {
791
807
  *s++ = '/';
792
808
  }
793
- strncpy(s, path, plen);
794
- s[plen] = '\0';
795
-
809
+ // TBD if path has % then ...
810
+ if (NULL != memchr(path, '%', plen)) {
811
+ const char *pend = path + plen;
812
+ const char *pp = path;
813
+
814
+ for (; pp < pend; pp++) {
815
+ if ('%' != *pp) {
816
+ *s++ = *pp;
817
+ continue;
818
+ }
819
+ *s++ = parse_percent_seq(pp+1);
820
+ pp += 2;
821
+ }
822
+ } else {
823
+ strncpy(s, path, plen);
824
+ s += plen;
825
+ }
826
+ *s = '\0';
827
+ plen = (int)(s - full_path);
796
828
  if (NULL == (page = cache_root_get(full_path, plen))) {
797
829
  if (NULL != cache.root) {
798
830
  agooPage old;
@@ -815,10 +847,12 @@ agoo_page_get(agooErr err, const char *path, int plen, const char *root) {
815
847
  }
816
848
  } else {
817
849
  if (NULL == (page = cache_get(path, plen))) {
818
- if (NULL != cache.root) {
850
+ bool has_percent = NULL != memchr(path, '%', plen);
851
+
852
+ if (NULL != cache.root || has_percent) {
819
853
  agooPage old;
820
- char full_path[2048];
821
- char *s = stpcpy(full_path, cache.root);
854
+ char full_path[2048];
855
+ char *s = stpcpy(full_path, cache.root);
822
856
 
823
857
  if ('/' != *cache.root && '/' != *path) {
824
858
  *s++ = '/';
@@ -827,17 +861,34 @@ agoo_page_get(agooErr err, const char *path, int plen, const char *root) {
827
861
  AGOO_ERR_MEM(err, "Page path");
828
862
  return NULL;
829
863
  }
830
- strncpy(s, path, plen);
831
- s[plen] = '\0';
832
- if (NULL == (page = agoo_page_create(full_path))) {
864
+ if (has_percent) {
865
+ const char *pend = path + plen;
866
+ const char *pp = path;
867
+
868
+ for (; pp < pend; pp++) {
869
+ if ('%' != *pp) {
870
+ *s++ = *pp;
871
+ continue;
872
+ }
873
+ *s++ = parse_percent_seq(pp+1);
874
+ pp += 2;
875
+ }
876
+ *s = '\0';
877
+ } else {
878
+ strncpy(s, path, plen);
879
+ s[plen] = '\0';
880
+ }
881
+ if (NULL == (page = agoo_page_create(full_path))) { // TBD full_path or original path?
833
882
  AGOO_ERR_MEM(err, "Page");
834
883
  return NULL;
835
884
  }
885
+ plen = (int)strlen(full_path);
836
886
  if (!update_contents(page) || NULL == page->resp) {
837
887
  agoo_page_destroy(page);
838
888
  agoo_err_set(err, AGOO_ERR_NOT_FOUND, "not found.");
839
889
  return NULL;
840
890
  }
891
+ // Cache key is the original path/plen.
841
892
  if (NULL != (old = cache_set(path, plen, page))) {
842
893
  agoo_page_destroy(old);
843
894
  }
data/lib/agoo/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
 
2
2
  module Agoo
3
3
  # Agoo version.
4
- VERSION = '2.15.2'
4
+ VERSION = '2.15.4'
5
5
  end
data/test/static_test.rb CHANGED
@@ -69,6 +69,25 @@ class StaticTest < Minitest::Test
69
69
  assert_equal(expect, content)
70
70
  end
71
71
 
72
+ def test_fetch_space_name
73
+ uri = URI('http://localhost:6469/space%20in%20name.html')
74
+ expect = %|<!DOCTYPE html>
75
+ <html>
76
+ <head><title>Agoo Space Test</title></head>
77
+ <body>Agoo</body>
78
+ </html>
79
+ |
80
+ req = Net::HTTP::Get.new(uri)
81
+ req['Accept-Encoding'] = '*'
82
+ req['User-Agent'] = 'Ruby'
83
+ res = Net::HTTP.start(uri.hostname, uri.port) { |h|
84
+ h.request(req)
85
+ }
86
+ content = res.body
87
+ assert_equal('text/html', res['Content-Type'])
88
+ assert_equal(expect, content)
89
+ end
90
+
72
91
  def test_mime
73
92
  uri = URI('http://localhost:6469/odd.odd')
74
93
  req = Net::HTTP::Get.new(uri)
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: agoo
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.15.2
4
+ version: 2.15.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Peter Ohler
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-06-21 00:00:00.000000000 Z
11
+ date: 2023-03-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: oj
@@ -190,7 +190,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
190
190
  version: '0'
191
191
  requirements:
192
192
  - Linux or macOS
193
- rubygems_version: 3.3.3
193
+ rubygems_version: 3.4.1
194
194
  signing_key:
195
195
  specification_version: 4
196
196
  summary: An HTTP server