You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@trafficserver.apache.org by zw...@apache.org on 2021/03/29 20:00:08 UTC

[trafficserver] branch 9.0.x updated: statichit: misc. fixes (#7634)

This is an automated email from the ASF dual-hosted git repository.

zwoop pushed a commit to branch 9.0.x
in repository https://gitbox.apache.org/repos/asf/trafficserver.git


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

commit bc6c338f58af841a6cccca43d07b2bac088a6af7
Author: Randall Meyer <rr...@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
    
    (cherry picked from commit a0c717dbe824fb2b5097f449014ac637fe00a850)
---
 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;