diff --git a/bti-030-comment_marker.patch b/bti-030-comment_marker.patch index 513d255..0a7d413 100644 --- a/bti-030-comment_marker.patch +++ b/bti-030-comment_marker.patch @@ -1,34 +1,43 @@ -From 211d649369fc07393a27542bf87a80d6211cb1a3 Mon Sep 17 00:00:00 2001 -From: Michel Alexandre Salim -Date: Fri, 18 Mar 2011 20:44:00 +0100 -Subject: [PATCH] Only treat # as a comment marker if it's at the beginning of line or is - preceded by a whitespace character - ---- - config.c | 10 ++++++++-- - 1 files changed, 8 insertions(+), 2 deletions(-) - diff --git a/config.c b/config.c -index 346fed8..9326c71 100644 +index 346fed8..674964b 100644 --- a/config.c +++ b/config.c -@@ -344,8 +344,14 @@ void bti_parse_configfile(struct session *session) +@@ -327,6 +327,7 @@ void bti_parse_configfile(struct session *session) + char *line = NULL; + char *key = NULL; + char *value = NULL; ++ char *hashmarker; + size_t len = 0; + ssize_t n; + char *c; +@@ -344,8 +345,28 @@ void bti_parse_configfile(struct session *session) if (line[n - 1] == '\n') line[n - 1] = '\0'; - /* '#' is comment markers, like bash style */ - *strchrnul(line, '#') = '\0'; -+ /* '#' is comment markers, like bash style -+ but it is a valid character in some fields, so -+ only treat it as a comment marker if it occurs -+ at the beginning of the line, or after whitespace */ -+ char *hashmarker = strchrnul(line, '#'); -+ if (line == hashmarker) line[0] = '\0'; -+ if (*(--hashmarker) == ' ' || *hashmarker == '\t') -+ *hashmarker = '\0'; ++ /* ++ * '#' is comment markers, like bash style but it is a valid ++ * character in some fields, so only treat it as a comment ++ * marker if it occurs at the beginning of the line, or after ++ * whitespace ++ */ ++ hashmarker = strchrnul(line, '#'); ++ if (line == hashmarker) ++ line[0] = '\0'; ++ else { ++ while (hashmarker[0] != '\0') { ++ --hashmarker; ++ if (isblank(hashmarker[0])) ++ hashmarker[0] = '\0'; ++ else { ++ /* false positive; '#' occured ++ * within a string ++ */ ++ hashmarker = strchrnul(hashmarker+2, '#'); ++ } ++ } ++ } c = line; while (isspace(*c)) c++; --- -1.7.4.1 - diff --git a/bti.spec b/bti.spec index 7d2db67..96f6f07 100644 --- a/bti.spec +++ b/bti.spec @@ -1,6 +1,6 @@ Name: bti Version: 030 -Release: 2%{?dist} +Release: 3%{?dist} Summary: Bash Twitter/Identi.ca Idiocy Group: Applications/Internet @@ -68,6 +68,10 @@ rm -rf $RPM_BUILD_ROOT %changelog +* Sat Mar 19 2011 Michel Salim - 030-3 +- Improved comment marker fix, now safer and handle lines containing both + non-marker and marker '#'s + * Fri Mar 18 2011 Michel Salim - 030-2 - Improve detection of comment marker in configuration file