summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAravinda VK <avishwan@redhat.com>2017-07-03 14:51:21 +0530
committerAravinda VK <avishwan@redhat.com>2017-07-21 04:43:58 +0000
commit5353389faf77bb2edb54e785c3d8aca323188dad (patch)
tree0f6edac0296bd5c097798443e318817dbcceb120
parent7517ee8a5795a85c1a877992c213199b0fd85517 (diff)
features/libgfchangelog: Fix encoding to encode only space and newline
libgfchangelog was encoding path using spec rfc3986, but encoding only required for SPACE and NEWLINE chars since the NEWLINE char is used as record separator and SPACE as field separator in the parsed changelogs output. Changed the encoding function to encode only SPACE and NEWLINE. BUG: 1451724 Change-Id: I4305459aab9e710517dd3eb065f0024503064b77 Signed-off-by: Aravinda VK <avishwan@redhat.com> Reviewed-on: https://review.gluster.org/17674 Smoke: Gluster Build System <jenkins@build.gluster.org> Reviewed-by: Prashanth Pai <ppai@redhat.com> CentOS-regression: Gluster Build System <jenkins@build.gluster.org> Reviewed-by: Kotresh HR <khiremat@redhat.com>
-rw-r--r--xlators/features/changelog/lib/src/gf-changelog-helpers.c2
-rw-r--r--xlators/features/changelog/lib/src/gf-changelog-helpers.h2
-rw-r--r--xlators/features/changelog/lib/src/gf-changelog-journal-handler.c16
-rw-r--r--xlators/features/changelog/lib/src/gf-changelog-journal.h2
4 files changed, 11 insertions, 11 deletions
diff --git a/xlators/features/changelog/lib/src/gf-changelog-helpers.c b/xlators/features/changelog/lib/src/gf-changelog-helpers.c
index 8b35f4e9416..45cf55778e4 100644
--- a/xlators/features/changelog/lib/src/gf-changelog-helpers.c
+++ b/xlators/features/changelog/lib/src/gf-changelog-helpers.c
@@ -36,7 +36,7 @@ gf_changelog_write (int fd, char *buffer, size_t len)
}
void
-gf_rfc3986_encode (unsigned char *s, char *enc, char *estr)
+gf_rfc3986_encode_space_newline (unsigned char *s, char *enc, char *estr)
{
for (; *s; s++) {
if (estr[*s])
diff --git a/xlators/features/changelog/lib/src/gf-changelog-helpers.h b/xlators/features/changelog/lib/src/gf-changelog-helpers.h
index bd21e4df035..b05628ee70d 100644
--- a/xlators/features/changelog/lib/src/gf-changelog-helpers.h
+++ b/xlators/features/changelog/lib/src/gf-changelog-helpers.h
@@ -209,7 +209,7 @@ ssize_t
gf_changelog_read_path (int fd, char *buffer, size_t bufsize);
void
-gf_rfc3986_encode (unsigned char *s, char *enc, char *estr);
+gf_rfc3986_encode_space_newline (unsigned char *s, char *enc, char *estr);
size_t
gf_changelog_write (int fd, char *buffer, size_t len);
diff --git a/xlators/features/changelog/lib/src/gf-changelog-journal-handler.c b/xlators/features/changelog/lib/src/gf-changelog-journal-handler.c
index e490069a165..f2fc25cc671 100644
--- a/xlators/features/changelog/lib/src/gf-changelog-journal-handler.c
+++ b/xlators/features/changelog/lib/src/gf-changelog-journal-handler.c
@@ -392,8 +392,10 @@ gf_changelog_parse_ascii (xlator_t *this,
break;
}
- gf_rfc3986_encode ((unsigned char *) ptr,
- eptr, jnl->rfc3986);
+ gf_rfc3986_encode_space_newline (
+ (unsigned char *) ptr,
+ eptr,
+ jnl->rfc3986_space_newline);
FILL_AND_MOVE (eptr, ascii, off,
mover, nleft, len);
free (eptr);
@@ -955,9 +957,8 @@ gf_changelog_init_history (xlator_t *this,
jnl->hist_jnl->jnl_brickpath[PATH_MAX-1] = 0;
for (i = 0; i < 256; i++) {
- jnl->hist_jnl->rfc3986[i] =
- (isalnum(i) || i == '~' ||
- i == '-' || i == '.' || i == '_') ? i : 0;
+ jnl->hist_jnl->rfc3986_space_newline[i] =
+ (i == ' ' || i == '\n' || i == '%') ? 0 : i;
}
return 0;
@@ -1026,9 +1027,8 @@ gf_changelog_journal_init (void *xl, struct gf_brick_spec *brick)
/* RFC 3986 {de,en}coding */
for (i = 0; i < 256; i++) {
- jnl->rfc3986[i] =
- (isalnum(i) || i == '~' ||
- i == '-' || i == '.' || i == '_') ? i : 0;
+ jnl->rfc3986_space_newline[i] =
+ (i == ' ' || i == '\n' || i == '%') ? 0 : i;
}
ret = gf_changelog_init_history (this, jnl, brick->brick_path);
diff --git a/xlators/features/changelog/lib/src/gf-changelog-journal.h b/xlators/features/changelog/lib/src/gf-changelog-journal.h
index e91807c80b6..46d50f159d9 100644
--- a/xlators/features/changelog/lib/src/gf-changelog-journal.h
+++ b/xlators/features/changelog/lib/src/gf-changelog-journal.h
@@ -53,7 +53,7 @@ typedef struct gf_changelog_journal {
char jnl_processed_dir[PATH_MAX];
char jnl_processing_dir[PATH_MAX];
- char rfc3986[256]; /* RFC 3986 string encoding */
+ char rfc3986_space_newline[256]; /* RFC 3986 string encoding */
struct gf_changelog_journal *hist_jnl;
int hist_done; /* holds 0 done scanning,