summaryrefslogtreecommitdiff
path: root/vms/vms.c
diff options
context:
space:
mode:
authorCraig A. Berry <craigberry@mac.com>2013-12-20 18:11:15 -0600
committerCraig A. Berry <craigberry@mac.com>2013-12-20 18:52:36 -0600
commit2e82b6ce46e012458b738a5c24d9ed52f5a54d3d (patch)
tree2426feaa30dba080f186d36737efb101da01ae54 /vms/vms.c
parent8da0169c5cf5e6fd8ad2fceb04286b6a44ca381d (diff)
downloadperl-2e82b6ce46e012458b738a5c24d9ed52f5a54d3d.tar.gz
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'.
Diffstat (limited to 'vms/vms.c')
-rw-r--r--vms/vms.c8
1 files changed, 2 insertions, 6 deletions
diff --git a/vms/vms.c b/vms/vms.c
index d1cb948581..cbc47d2b08 100644
--- a/vms/vms.c
+++ b/vms/vms.c
@@ -8537,9 +8537,6 @@ static char *int_tovmsspec
}
else *(cp1++) = '.';
}
- else {
- *(cp1++) = *cp2;
- }
for (; cp2 < dirend; cp2++) {
if (*cp2 == '/') {
if (*(cp2-1) == '/') continue;
@@ -8597,8 +8594,7 @@ static char *int_tovmsspec
}
if (cp1 > 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++;