--- weex-2.6.1.orig/src/ftplib.c
+++ weex-2.6.1/src/ftplib.c
@@ -422,7 +422,11 @@
 
     memset(&sin,0,sizeof(sin));
     sin.sin_family = AF_INET;
-    lhost = strdup(host);
+    if (strncmp(host, "ftp://", 6) == 0) {
+	    lhost = strdup(host + 6);
+    } else {
+	    lhost = strdup(host);
+    }
     pnum = strchr(lhost,':');
     if (pnum == NULL)
     {
@@ -444,7 +448,11 @@
 	    sin.sin_port = htons(atoi(pnum));
 	else
 	{
-	    pse = getservbyname(pnum,"tcp");
+   	if ((pse = getservbyname(pnum,"tcp")) == NULL)
+	    {
+		/* perror("getservbyname"); */
+		return 0;
+	    }
 	    sin.sin_port = pse->s_port;
 	}
     }
@@ -603,6 +611,37 @@
     return FtpSendCmd(tempbuf,'2',nControl);
 }
 
+/* 
+ * FtpAuthorize - authorize FTP proxy to send outgoing data; requires
+ * user interaction with cryptokey
+ */
+GLOBALDEF int FtpAuthorize(const char *user, netbuf *nControl)
+{
+    char tempbuf[64], respbuf[32];
+    char *newline;
+
+    if ((strlen(user) + 12) > sizeof(tempbuf))
+        return 0;
+    sprintf(tempbuf,"AUTHORIZE %s",user);
+    if (!FtpSendCmd(tempbuf,'3',nControl))
+    {
+	if (nControl->response[0] == '2')
+	    return 1;
+	return 0;
+    }
+    fputs(nControl->response, stderr);
+    respbuf[0] = '\0';
+    fgets(respbuf, sizeof(respbuf), stdin);
+    newline = strchr(respbuf, '\n');
+    if (newline) *newline = '\0';
+    sprintf(tempbuf,"RESPONSE %s",respbuf);
+    if (!FtpSendCmd(tempbuf,'2',nControl)){
+      fprintf(stderr, "%s", nControl->response);
+      return 0;
+    }
+    return 1;
+}
+
 /*
  * FtpOpenPort - set up data connection
  *
