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/02/11 03:57:42 UTC
[trafficserver] branch 9.0.x updated: Change comment handling for
long lines in url_sig plugin (#7421)
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 ed1b401 Change comment handling for long lines in url_sig plugin (#7421)
ed1b401 is described below
commit ed1b401c0c420e759a96c5141942c4b0165228a6
Author: Evan Zelkowitz <ez...@apache.org>
AuthorDate: Thu Jan 14 17:02:34 2021 -0700
Change comment handling for long lines in url_sig plugin (#7421)
Change comment handling for long lines
There is a 300char max buffer size on lines url sig. If there is a comment longer than this then it will show up in the next fgets. If that happens to contain an `=` then it may end up being parsed as a rule otherwise it is thrown away but has an error printed.
This changes the comment handling so that if there is no `\n` seen at the end of the string in the buffer then it is assumed it is a long comment line and urlsig will continue eating the buffer until it hits a `\n`
(cherry picked from commit 08fe521a3974a05b01545c68fe1bcd5162dd4fc4)
---
plugins/experimental/url_sig/url_sig.c | 13 +++++++++++++
tests/gold_tests/pluginTest/url_sig/url_sig.config | 1 +
tests/gold_tests/pluginTest/url_sig/url_sig.test.py | 1 +
3 files changed, 15 insertions(+)
diff --git a/plugins/experimental/url_sig/url_sig.c b/plugins/experimental/url_sig/url_sig.c
index 249a011..f6ad41b 100644
--- a/plugins/experimental/url_sig/url_sig.c
+++ b/plugins/experimental/url_sig/url_sig.c
@@ -134,6 +134,7 @@ TSRemapNewInstance(int argc, char *argv[], void **ih, char *errbuf, int errbuf_s
char line[300];
int line_no = 0;
int keynum;
+ bool eat_comment = false;
cfg = TSmalloc(sizeof(struct config));
memset(cfg, 0, sizeof(struct config));
@@ -141,7 +142,19 @@ TSRemapNewInstance(int argc, char *argv[], void **ih, char *errbuf, int errbuf_s
while (fgets(line, sizeof(line), file) != NULL) {
TSDebug(PLUGIN_NAME, "LINE: %s (%d)", line, (int)strlen(line));
line_no++;
+
+ if (eat_comment) {
+ // Check if final char is EOL, if so we are done eating
+ if (line[strlen(line) - 1] == '\n') {
+ eat_comment = false;
+ }
+ continue;
+ }
if (line[0] == '#' || strlen(line) <= 1) {
+ // Check if we have a comment longer than the full buffer if no EOL
+ if (line[strlen(line) - 1] != '\n') {
+ eat_comment = true;
+ }
continue;
}
char *pos = strchr(line, '=');
diff --git a/tests/gold_tests/pluginTest/url_sig/url_sig.config b/tests/gold_tests/pluginTest/url_sig/url_sig.config
index 7c10a6b..7618f6c 100644
--- a/tests/gold_tests/pluginTest/url_sig/url_sig.config
+++ b/tests/gold_tests/pluginTest/url_sig/url_sig.config
@@ -1,3 +1,4 @@
+#This is a very long test line. This is a very long test line. This is a very long test line. This is a very long test line. This is a very long test line. This is a very long test line. This is a very long test line. This is a very long test line. This is a very long test line. This is a very long test line. This is a very long test line. This is a very long test line. This is a very long test line. This is a very long test line. This is a very long test line. This is a very long test l [...]
key0 = hV3wqyq1QxJeF76JkzHf93tuLYv_abw5
key1 = nIpyXbVqPFVN7y8yMlfgFBLnOqDSufMy
key2 = 4UED1ELmHkEcXrS_7yEYPKtgUZdGWaP2
diff --git a/tests/gold_tests/pluginTest/url_sig/url_sig.test.py b/tests/gold_tests/pluginTest/url_sig/url_sig.test.py
index 588f6d6..9a4ac8e 100644
--- a/tests/gold_tests/pluginTest/url_sig/url_sig.test.py
+++ b/tests/gold_tests/pluginTest/url_sig/url_sig.test.py
@@ -264,3 +264,4 @@ tr.Processes.Default.Command = (
# Overriding the built in ERROR check since we expect some ERROR messages
ts.Disk.diags_log.Content = Testers.ContainsExpression("ERROR", "Some tests are failure tests")
+ts.Disk.diags_log.Content += Testers.ExcludesExpression("Error parsing", "Verify that we can accept long comment lines")