trafficserver-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From r..@apache.org
Subject [trafficserver] branch master updated: statichit: misc. fixes (#7634)
Date Sat, 27 Mar 2021 21:53:20 GMT
This is an automated email from the ASF dual-hosted git repository.

rrm pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/trafficserver.git


The following commit(s) were added to refs/heads/master by this push:
     new a0c717d  statichit: misc. fixes (#7634)
a0c717d is described below

commit a0c717dbe824fb2b5097f449014ac637fe00a850
Author: Randall Meyer <rrm@apache.org>
AuthorDate: Sat Mar 27 14:53:07 2021 -0700

    statichit: misc. fixes (#7634)
    
    Anchor request to remapped path and allow for relative --file-paths
---
 plugins/experimental/statichit/statichit.cc | 13 +++++++++++++
 1 file changed, 13 insertions(+)

diff --git a/plugins/experimental/statichit/statichit.cc b/plugins/experimental/statichit/statichit.cc
index b362ba4..8f06be1 100644
--- a/plugins/experimental/statichit/statichit.cc
+++ b/plugins/experimental/statichit/statichit.cc
@@ -571,6 +571,15 @@ TSRemapDoRemap(void *ih, TSHttpTxn rh, TSRemapRequestInfo *rri)
     return TSREMAP_NO_REMAP;
   }
 
+  // Anchor to URL specified in remap
+  int pathsz;
+  TSUrlPathGet(rri->requestBufp, rri->requestUrl, &pathsz);
+  if (pathsz > 0) {
+    VERROR("Path is not an exact match. Rejecting!");
+    TSHttpTxnStatusSet(rh, TS_HTTP_STATUS_NOT_FOUND);
+    return TSREMAP_NO_REMAP;
+  }
+
   if (!cfg->maxAge) {
     TSHttpTxnConfigIntSet(rh, TS_CONFIG_HTTP_CACHE_HTTP, 0);
     StaticHitSetupIntercept(static_cast<StaticHitConfig *>(ih), rh);
@@ -631,6 +640,10 @@ TSRemapNewInstance(int argc, char *argv[], void **ih, char * /* errbuf
ATS_UNUSE
     return TS_ERROR;
   }
 
+  if (filePath.find("/") != 0) {
+    filePath = std::string(TSConfigDirGet()) + '/' + filePath;
+  }
+
   StaticHitConfig *tc = new StaticHitConfig(filePath, mimeType);
   if (maxAge > 0) {
     tc->maxAge = maxAge;

Mime
View raw message