--- scp.c.orig	2005-07-26 11:30:03.000000000 +0200
+++ scp.c	2005-07-26 11:32:21.000000000 +0200
@@ -359,11 +359,46 @@
 {
 	int i, len;
 	char *bp, *host, *src, *suser, *thost, *tuser, *arg;
+        char *quote_targ = 0;
 
 	*targ++ = 0;
 	if (*targ == 0)
 		targ = ".";
 
+        {
+          int c, qc;
+
+          if (verbose_mode)
+            fprintf(stderr, "Unquoted target: \"%s\"\n", targ);
+          quote_targ = xmalloc(strlen(targ)*2+1);
+          for (c=qc=0; c < strlen(targ); c++, qc++) {
+            switch (targ[c]) {
+            case ' ':
+            case ':':
+            case '(':
+            case ')':
+            case '[':
+            case ']':
+            case '<':
+            case '>':
+            case ';':
+            case '|':
+            case '&':
+            case '\\':
+              quote_targ[qc] = '\\';
+              qc++;
+              break;
+            default:
+              break;
+            }
+            quote_targ[qc] = targ[c];
+          }
+          quote_targ[qc] = 0;
+          targ = quote_targ;
+          if (verbose_mode)
+            fprintf(stderr, "Quoted target = \"%s\"\n", targ);
+        }
+
 	arg = xstrdup(argv[argc - 1]);
 	if ((thost = strrchr(arg, '@'))) {
 		/* user@host */
@@ -442,6 +477,8 @@
 			source(1, argv + i);
 		}
 	}
+        if (quote_targ)
+          xfree(quote_targ);
 }
 
 void
@@ -449,6 +486,7 @@
 {
 	int i, len;
 	char *bp, *host, *src, *suser;
+        char *quote_src = 0;
 
 	for (i = 0; i < argc - 1; i++) {
 		if (!(src = colon(argv[i]))) {	/* Local to local. */
@@ -468,6 +506,41 @@
 		*src++ = 0;
 		if (*src == 0)
 			src = ".";
+
+                {
+                  int c, qc;
+
+                  if (verbose_mode)
+                    fprintf(stderr, "Unquoted source: \"%s\"\n", src);
+                  quote_src = xmalloc(strlen(src)*2+1);
+                  for (c=qc=0; c < strlen(src); c++, qc++) {
+                    switch (src[c]) {
+                    case ' ':
+                    case ':':
+                    case '(':
+                    case ')':
+                    case '[':
+                    case ']':
+                    case '<':
+                    case '>':
+                    case ';':
+                    case '|':
+                    case '&':
+                    case '\\':
+                      quote_src[qc] = '\\';
+                      qc++;
+                      break;
+                    default:
+                      break;
+                    }
+                    quote_src[qc] = src[c];
+                  }
+                  quote_src[qc] = 0;
+                  src = quote_src;
+                  if (verbose_mode)
+                    fprintf(stderr, "Quoted source = \"%s\"\n", src);
+                }
+
 		if ((host = strrchr(argv[i], '@')) == NULL) {
 			host = argv[i];
 			suser = NULL;
@@ -491,6 +564,8 @@
 		(void) close(remin);
 		remin = remout = -1;
 	}
+        if (quote_src)
+          xfree(quote_src);
 }
 
 void
