+2008-02-21 Koji Arai <arai@users.sourceforge.jp>
+
+ * src/header.c (canon_path): should remove duplicated slash.
+ (the function name is renamed from remove_dots().)
+
+ * tests/lha-test17: added a test for above.
+
2008-02-17 Koji Arai <arai@users.sourceforge.jp>
* src/lhext.c (extract_one) could not extract files under readonly directories, like:
# Process this file with autoconf to produce a configure script.
-AC_INIT([LHa for UNIX], 1.14i-ac20080217, arai@users.sourceforge.jp, lha)
+AC_INIT([LHa for UNIX], 1.14i-ac20080221, arai@users.sourceforge.jp, lha)
AC_DEFINE_UNQUOTED(LHA_CONFIGURE_OPTIONS, "$ac_configure_args",
[specified options for the configure script.])
AC_CANONICAL_HOST
return i;
}
-/* remove leading "xxx/../" and "./" */
+/*
+ canonicalize path
+
+ remove leading "xxx/../"
+ remove "./", "././", "././ ... ./"
+ remove duplicated "/"
+*/
static int
-remove_dots(char *newpath, char *path, size_t size)
+canon_path(char *newpath, char *path, size_t size)
{
int len;
char *p = newpath;
if (size <= 1)
break;
}
+
+ /* remove duplicated '/' */
+ while (*path == '/') path++;
}
/* When newpath is empty, set "." */
hdr->attribute = GENERIC_ATTRIBUTE;
hdr->header_level = header_level;
- len = remove_dots(hdr->name, name, sizeof(hdr->name));
+ len = canon_path(hdr->name, name, sizeof(hdr->name));
hdr->crc = 0x0000;
hdr->extend_type = EXTEND_UNIX;
egrep -v -- '-lh' test-tmp-stdout | diff - test-tmp-expect
check $? $LINENO
echo -------------------------------------------------------------------
+# remove duplicated slash "xxx//xxx" -> "xxx/xxx"
+(cd test-1 &&
+ $lha c $builddir/test-tmp-10.lzh ./test-a .//test-b .///test-c
+ )
+ check $? $LINENO
+$lha a test-tmp-10.lzh ./test-1/test-a .//test-1//test-b .///test-1///test-c
+
+$lha vvq test-tmp-10.lzh
+$lha vvq test-tmp-10.lzh > test-tmp-stdout
+ check $? $LINENO
+# followings is sorted by argument strings.
+# XXX: this behavior is undesirable.
+cat <<"EOF" > test-tmp-expect
+test-1/test-c
+test-1/test-b
+test-1/test-a
+test-c
+test-b
+test-a
+EOF
+
+egrep -v -- '-lh' test-tmp-stdout | diff - test-tmp-expect
+ check $? $LINENO
+echo -------------------------------------------------------------------