From 042ecacd0f6cdbb5a7ed848d4fdf11df6672e70c Mon Sep 17 00:00:00 2001 From: Patryk Kaczmarek Date: Tue, 18 Sep 2012 11:34:36 +0000 Subject: [PATCH] From: Patryk Kaczmarek Subject: [E-devel] [Patch] [Ecore] ecore_file_escape_name fix for \n and \t Please review and consider the attached patch for ecore_file_escape_name function, now it correctly escapes tab and new line characters. SVN revision: 76803 --- legacy/ecore/AUTHORS | 1 + legacy/ecore/ChangeLog | 5 +++ legacy/ecore/NEWS | 1 + legacy/ecore/src/lib/ecore_file/ecore_file.c | 38 +++++++++++++++----- 4 files changed, 37 insertions(+), 8 deletions(-) diff --git a/legacy/ecore/AUTHORS b/legacy/ecore/AUTHORS index 2cd3b467bc..e16e1e8fac 100644 --- a/legacy/ecore/AUTHORS +++ b/legacy/ecore/AUTHORS @@ -53,3 +53,4 @@ Haifeng Deng Jérémy Zurcher Vikram Narayanan Seong-ho Cho (DarkCircle) +Patryk Kaczmarek diff --git a/legacy/ecore/ChangeLog b/legacy/ecore/ChangeLog index c757805aa6..e27c9c2899 100644 --- a/legacy/ecore/ChangeLog +++ b/legacy/ecore/ChangeLog @@ -951,3 +951,8 @@ * Add string to atom_items for ECORE_X_ATOM_E_ILLUME_WINDOW_STATE, ECORE_X_ATOM_E_ILLUME_WINDOW_STATE_NORMAL, ECORE_X_ATOM_E_ILLUME_WINDOW_STATE_FLOATING +2012-09-18 Patryk Kaczmarek + + * Fix escaping in ecore_file_escape_name() to handle tab and + newline right. + diff --git a/legacy/ecore/NEWS b/legacy/ecore/NEWS index 39aea60693..7503e77950 100644 --- a/legacy/ecore/NEWS +++ b/legacy/ecore/NEWS @@ -22,6 +22,7 @@ Fixes: - Timeouts are handled correctly now (passing HTTP status 408 to completion callback). * ecore_evas rotation handling on some driver implementations + * ecore_file_escape_name() escape taba nd newline right. Improvements: diff --git a/legacy/ecore/src/lib/ecore_file/ecore_file.c b/legacy/ecore/src/lib/ecore_file/ecore_file.c index cc0be5449d..e8400ca57d 100644 --- a/legacy/ecore/src/lib/ecore_file/ecore_file.c +++ b/legacy/ecore/src/lib/ecore_file/ecore_file.c @@ -1017,19 +1017,41 @@ ecore_file_escape_name(const char *filename) { if ((q - buf) > (PATH_MAX - 6)) return NULL; if ( - (*p == ' ') || (*p == '\t') || (*p == '\n') || - (*p == '\\') || (*p == '\'') || (*p == '\"') || - (*p == ';') || (*p == '!') || (*p == '#') || - (*p == '$') || (*p == '%') || (*p == '&') || - (*p == '*') || (*p == '(') || (*p == ')') || - (*p == '[') || (*p == ']') || (*p == '{') || - (*p == '}') || (*p == '|') || (*p == '<') || - (*p == '>') || (*p == '?') + (*p == ' ') || (*p == '\\') || (*p == '\'') || + (*p == '\"') || (*p == ';') || (*p == '!') || + (*p == '#') || (*p == '$') || (*p == '%') || + (*p == '&') || (*p == '*') || (*p == '(') || + (*p == ')') || (*p == '[') || (*p == ']') || + (*p == '{') || (*p == '}') || (*p == '|') || + (*p == '<') || (*p == '>') || (*p == '?') ) { *q = '\\'; q++; } + else if (*p == '\t') + { + *q = '\\'; + q++; + *q = '\\'; + q++; + *q = 't'; + q++; + p++; + continue; + } + else if (*p == '\n') + { + *q = '\\'; + q++; + *q = '\\'; + q++; + *q = 'n'; + q++; + p++; + continue; + } + *q = *p; q++; p++;