Fossil

Diff
Login

Differences From Artifact [5a9c0f9dfc]:

To Artifact [ce3ed13eec]:


431
432
433
434
435
436
437



















438
439
440
441
442
443
444
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463







+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+







}
NORETURN void cgi_redirectf(const char *zFormat, ...){
  va_list ap;
  va_start(ap, zFormat);
  cgi_redirect(vmprintf(zFormat, ap));
  va_end(ap);
}

/*
** Add a "Content-disposition: attachment; filename=%s" header to the reply.
*/
void cgi_content_disposition_filename(const char *zFilename){
                 /*  0123456789 123456789 123456789 123456789 123456*/
  char *z = mprintf("Content-Disposition: attachment; filename=\"%s\";\r\n",
                    zFilename);
  int i;
  int n = (int)strlen(z);
  for(i=43; i<n-4; i++){
    char c = z[i];
    if( isalnum(c) ) continue;
    if( c=='.' || c=='-' || c=='/' ) continue;
    z[i] = '_';
  }
  cgi_append_header(z);
  fossil_free(z);
}

/*
** Return the URL for the caller.  This is obtained from either the
** referer CGI parameter, if it exists, or the HTTP_REFERER HTTP parameter.
** If neither exist, return zDefault.
*/
const char *cgi_referer(const char *zDefault){