cURL / Mailing Lists / curl-library / Single Mail

curl-library

cut off traling params from curl -O filename

From: Guenter <lists_at_gknw.net>
Date: Fri, 20 Aug 2010 16:23:57 +0200

Hi,
not sure if there is not a more elegant solution so I post the patch
here first:

--- src/main.c.orig Fri Aug 20 04:00:06 2010
+++ src/main.c Fri Aug 20 16:06:07 2010
@@ -4312,12 +4312,18 @@
      pc+=3;
    else
      pc=url;
- pc = strrchr(pc, '/');

- if(pc) {
+ if((pc = strrchr(pc, '/'))) {
      /* duplicate the string beyond the slash */
      pc++;
- fn = *pc ? strdup(pc): NULL;
+ if(*pc) {
+ char *par = NULL;
+ fn = strdup(pc);
+ if((par = strchr(fn, '?'))) {
+ /* cut off the question mark and everything beyond */
+ *par = '\0';
+ }
+ }
    }
    return fn;
  }

comments?

Gün.

-------------------------------------------------------------------
List admin: http://cool.haxx.se/list/listinfo/curl-library
Etiquette: http://curl.haxx.se/mail/etiquette.html
Received on 2010-08-20