You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@trafficserver.apache.org by ez...@apache.org on 2021/01/15 00:02:47 UTC
[trafficserver] branch master updated: Change comment handling for
long lines in url_sig plugin (#7421)
This is an automated email from the ASF dual-hosted git repository.
eze 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 08fe521 Change comment handling for long lines in url_sig plugin (#7421)
08fe521 is described below
commit 08fe521a3974a05b01545c68fe1bcd5162dd4fc4
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`
---
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 d08f9da..6e20cc2 100644
--- a/plugins/experimental/url_sig/url_sig.c
+++ b/plugins/experimental/url_sig/url_sig.c
@@ -135,6 +135,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));
@@ -142,7 +143,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 aee7d1c..07e993d 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")