Fossil

Check-in [f488a5aa]
Login

Check-in [f488a5aa]

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Patched cgi_set_cookie() to be a no-op when not running in HTTP(s) mode (e.g. in JSON CLI mode), since g.zTop is not set in that case. Resolves a segfault reported on the ML.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: f488a5aa97a3b15f57e13b4a1f060b62b3a5fdf1b1bc1bd0c057cae611d74b7f
User & Date: stephan 2018-07-05 16:51:12
Context
2018-07-07
20:14
Fix annotate_file() so that it correctly errors out if the named file does not exist in the revision. ... (check-in: ae73e4ed user: ashepilko tags: trunk)
2018-07-05
16:51
Patched cgi_set_cookie() to be a no-op when not running in HTTP(s) mode (e.g. in JSON CLI mode), since g.zTop is not set in that case. Resolves a segfault reported on the ML. ... (check-in: f488a5aa user: stephan tags: trunk)
2018-07-03
10:23
Only add the default <body> element to the header if the configured header lacks "<body". Formerly, it searched for "<body>" and that search would fail if the body element contained attributes. ToDo: This default body-element mechanism needs to be better documented. ... (check-in: 24ecb3bb user: drh tags: trunk)
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to src/cgi.c.

198
199
200
201
202
203
204
205

206
207
208
209
210
211
212
213
214
215

216
217
218
219
220
221
222
223
** Append text to the header of an HTTP reply
*/
void cgi_append_header(const char *zLine){
  blob_append(&extraHeader, zLine, -1);
}

/*
** Set a cookie.

**
** Zero lifetime implies a session cookie.
*/
void cgi_set_cookie(
  const char *zName,    /* Name of the cookie */
  const char *zValue,   /* Value of the cookie.  Automatically escaped */
  const char *zPath,    /* Path cookie applies to.  NULL means "/" */
  int lifetime          /* Expiration of the cookie in seconds from now */
){
  char *zSecure = "";

  if( zPath==0 ){
    zPath = g.zTop;
    if( zPath[0]==0 ) zPath = "/";
  }
  if( g.zBaseURL!=0 && strncmp(g.zBaseURL, "https:", 6)==0 ){
    zSecure = " secure;";
  }
  if( lifetime>0 ){







|
>









|
>
|







198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
** Append text to the header of an HTTP reply
*/
void cgi_append_header(const char *zLine){
  blob_append(&extraHeader, zLine, -1);
}

/*
** Set a cookie by queuing up the appropriate HTTP header output. If
** !g.isHTTP, this is a no-op.
**
** Zero lifetime implies a session cookie.
*/
void cgi_set_cookie(
  const char *zName,    /* Name of the cookie */
  const char *zValue,   /* Value of the cookie.  Automatically escaped */
  const char *zPath,    /* Path cookie applies to.  NULL means "/" */
  int lifetime          /* Expiration of the cookie in seconds from now */
){
  char const *zSecure = "";
  if(!g.isHTTP) return /* e.g. JSON CLI mode, where g.zTop is not set */;
  else if( zPath==0 ){
    zPath = g.zTop;
    if( zPath[0]==0 ) zPath = "/";
  }
  if( g.zBaseURL!=0 && strncmp(g.zBaseURL, "https:", 6)==0 ){
    zSecure = " secure;";
  }
  if( lifetime>0 ){