Skip to content

Commit 6f9dcdd

Browse files
authored
ISO8601 high priority, before UNIX timestamp
1 parent 8c54492 commit 6f9dcdd

File tree

1 file changed

+17
-15
lines changed

1 file changed

+17
-15
lines changed

ngx_http_hmac_secure_link_module.c

+17-15
Original file line numberDiff line numberDiff line change
@@ -157,21 +157,12 @@ ngx_http_secure_link_variable(ngx_http_request_t *r,
157157
"secure link timestamp: \"%*s\"",
158158
sizeof("1970-09-28T12:00:00+06:00")-1, p);
159159

160-
/* Try if p is UNIX timestamp*/
161-
if (sscanf((char *)p, "%llu", &conv_timestamp) == 1) {
162-
timestamp = (time_t)conv_timestamp;
163-
164-
ngx_log_debug1(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,
165-
"secure link timestamp: \"%T\"", timestamp);
166-
} else {
167-
/* Parse timestamp in ISO8601 format */
168-
if (sscanf((char *)p, "%4d-%02d-%02dT%02d:%02d:%02d%c%02i:%02i",
169-
(ngx_tm_year_t *) &year, (ngx_tm_mon_t *) &month,
170-
(ngx_tm_mday_t *) &mday, (ngx_tm_hour_t *) &hour,
171-
(ngx_tm_min_t *) &min, (ngx_tm_sec_t *) &sec,
172-
&gmtoff_sign, &gmtoff_hour, &gmtoff_min) < 9) {
173-
goto not_found;
174-
}
160+
/* Parse timestamp in ISO8601 format */
161+
if (sscanf((char *)p, "%4d-%02d-%02dT%02d:%02d:%02d%c%02i:%02i",
162+
(ngx_tm_year_t *) &year, (ngx_tm_mon_t *) &month,
163+
(ngx_tm_mday_t *) &mday, (ngx_tm_hour_t *) &hour,
164+
(ngx_tm_min_t *) &min, (ngx_tm_sec_t *) &sec,
165+
&gmtoff_sign, &gmtoff_hour, &gmtoff_min) == 9) {
175166

176167
/* Put February last because it has leap day */
177168
month -= 2;
@@ -208,6 +199,17 @@ ngx_http_secure_link_variable(ngx_http_request_t *r,
208199

209200
ngx_log_debug1(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,
210201
"secure link timestamp: \"%T\"", timestamp);
202+
203+
} else if (sscanf((char *)p, "%llu", &conv_timestamp) == 1) {
204+
/* Try if p is UNIX timestamp */
205+
206+
timestamp = (time_t)conv_timestamp;
207+
208+
ngx_log_debug1(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,
209+
"secure link timestamp: \"%T\"", timestamp);
210+
211+
} else {
212+
goto not_found;
211213
}
212214

213215
if (timestamp <= 0) {

0 commit comments

Comments
 (0)