From: David Barr <david.barr@xxxxxxxxxxxx> Date: Sun, 12 Dec 2010 03:59:31 +1100 Subject: [PATCH] vcs-svn: quote paths correctly for ls command This bug was found while importing rev 601865 of ASF. Signed-off-by: David Barr <david.barr@xxxxxxxxxxxx> --- vcs-svn/fast_export.c | 4 ++-- vcs-svn/string_pool.c | 11 +++++++++++ vcs-svn/string_pool.h | 1 + 3 files changed, 14 insertions(+), 2 deletions(-) diff --git a/vcs-svn/fast_export.c b/vcs-svn/fast_export.c index c798f6d..d2397d8 100644 --- a/vcs-svn/fast_export.c +++ b/vcs-svn/fast_export.c @@ -100,7 +100,7 @@ static void ls_from_rev(uint32_t rev, const uint32_t *path) { /* ls :5 "path/to/old/file" */ printf("ls :%"PRIu32" \"", rev); - pool_print_seq(REPO_MAX_PATH_DEPTH, path, '/', stdout); + pool_print_seq_q(REPO_MAX_PATH_DEPTH, path, '/', stdout); printf("\"\n"); fflush(stdout); } @@ -149,7 +149,7 @@ void fast_export_ls(const uint32_t *path, uint32_t *mode, struct strbuf *dataref) { printf("ls \""); - pool_print_seq(REPO_MAX_PATH_DEPTH, path, '/', stdout); + pool_print_seq_q(REPO_MAX_PATH_DEPTH, path, '/', stdout); printf("\"\n"); fflush(stdout); parse_ls_response(get_response_line(), mode, dataref); diff --git a/vcs-svn/string_pool.c b/vcs-svn/string_pool.c index c08abac..a03f5a4 100644 --- a/vcs-svn/string_pool.c +++ b/vcs-svn/string_pool.c @@ -4,6 +4,8 @@ */ #include "git-compat-util.h" +#include "strbuf.h" +#include "quote.h" #include "trp.h" #include "obj_pool.h" #include "string_pool.h" @@ -75,6 +77,15 @@ void pool_print_seq(uint32_t len, const uint32_t *seq, char delim, FILE *stream) } } +void pool_print_seq_q(uint32_t len, const uint32_t *seq, char delim, FILE *stream) +{ + uint32_t i; + for (i = 0; i < len && ~seq[i]; i++) { + quote_c_style(pool_fetch(seq[i]), NULL, stream, 1); + if (i < len - 1 && ~seq[i + 1]) + fputc(delim, stream); + } +} uint32_t pool_tok_seq(uint32_t sz, uint32_t *seq, const char *delim, char *str) { char *context = NULL; diff --git a/vcs-svn/string_pool.h b/vcs-svn/string_pool.h index 3720cf8..96e501d 100644 --- a/vcs-svn/string_pool.h +++ b/vcs-svn/string_pool.h @@ -5,6 +5,7 @@ uint32_t pool_intern(const char *key); const char *pool_fetch(uint32_t entry); uint32_t pool_tok_r(char *str, const char *delim, char **saveptr); void pool_print_seq(uint32_t len, const uint32_t *seq, char delim, FILE *stream); +void pool_print_seq_q(uint32_t len, const uint32_t *seq, char delim, FILE *stream); uint32_t pool_tok_seq(uint32_t sz, uint32_t *seq, const char *delim, char *str); void pool_reset(void); -- 1.7.3.2.846.gf4b062 -- To unsubscribe from this list: send the line "unsubscribe git" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html