agoo 2.15.2 → 2.15.4
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 +4 -4
- data/CHANGELOG.md +13 -0
- data/README.md +1 -1
- data/ext/agoo/extconf.rb +1 -0
- data/ext/agoo/page.c +70 -19
- data/lib/agoo/version.rb +1 -1
- data/test/static_test.rb +19 -0
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f4f9e647ee51b00410d85de35a301d61dd6795175a2add858d29b4777d5889fb
|
4
|
+
data.tar.gz: 707f1a41efc1f051c15f661774063b45e48f989377d14c9c5cf59579fb962f68
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
# [](http://www.ohler.com/agoo) Agoo
|
2
2
|
|
3
|
-
[](https://github.com/ohler55/agoo/actions/workflows/CI.yml)
|
3
|
+
[](https://github.com/ohler55/agoo/actions/workflows/CI.yml)
|
4
4
|
[](https://badge.fury.io/rb/agoo)
|
5
5
|
 [](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
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
|
-
|
794
|
-
|
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
|
-
|
850
|
+
bool has_percent = NULL != memchr(path, '%', plen);
|
851
|
+
|
852
|
+
if (NULL != cache.root || has_percent) {
|
819
853
|
agooPage old;
|
820
|
-
char
|
821
|
-
char
|
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
|
-
|
831
|
-
|
832
|
-
|
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
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.
|
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:
|
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.
|
193
|
+
rubygems_version: 3.4.1
|
194
194
|
signing_key:
|
195
195
|
specification_version: 4
|
196
196
|
summary: An HTTP server
|