From 2e82b6ce46e012458b738a5c24d9ed52f5a54d3d Mon Sep 17 00:00:00 2001 From: "Craig A. Berry" Date: Fri, 20 Dec 2013 18:11:15 -0600 Subject: [PATCH] Fix unescaped first character in tovmsspec. Passing a path to int_tovmsspec that contained an "extended" character as the first character when converting a Unix filespec to VMS format skipped escaping that character, but only when the path spec had no directory component. The character that didn't get escaped could then be passed to a native service that choked or incorrectly processed it. For example ' foo.txt' remained, after translation, ' foo.txt', but parsing that as a native spec would squeeze out the leading space. So we now make sure we don't eat the first character of the filename component while processing the directory component and also handle escaping the very first character. In the example of ' foo.txt', it now gets correctly translated to '^_foo.txt'. --- ext/VMS-Filespec/t/filespec.t | 4 +++- vms/vms.c | 8 ++------ 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/ext/VMS-Filespec/t/filespec.t b/ext/VMS-Filespec/t/filespec.t index f84efb3..09ee7f9 100644 --- a/ext/VMS-Filespec/t/filespec.t +++ b/ext/VMS-Filespec/t/filespec.t @@ -31,8 +31,9 @@ if ($^O eq 'VMS') { foreach $test (@tests) { - ($arg,$func,$expect2,$expect5) = split(/\s+/,$test); + ($arg,$func,$expect2,$expect5) = split(/(? rslt && *(cp1-1) == '.') cp1--; /* Unix spec ending in '/' ==> trailing '.' */ if (hasdir) *(cp1++) = ']'; - if (*cp2) cp2++; /* check in case we ended with trailing '..' */ - /* fixme for ODS5 */ + if (*cp2 && *cp2 == '/') cp2++; /* check in case we ended with trailing '/' */ no_type_seen = 0; if (cp2 > lastdot) no_type_seen = 1; @@ -8611,7 +8607,7 @@ static char *int_tovmsspec *(cp1++) = '?'; cp2++; case ' ': - if (cp2 > path && *(cp2-1) != '^') /* not previously escaped */ + if (cp2 >= path && (cp2 == path || *(cp2-1) != '^')) /* not previously escaped */ *(cp1)++ = '^'; *(cp1)++ = '_'; cp2++; -- 2.7.4