Fossil

Diff
Login

Differences From Artifact [ecc49bf32d]:

To Artifact [740f642e22]:


1300
1301
1302
1303
1304
1305
1306

1307
1308



1309
1310

1311
1312



1313
1314
1315
1316

1317
1318



1319
1320

1321
1322



1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334

1335
1336
1337



1338
1339

1340
1341

1342
1343
1344
1345
1346
1347
1348
1300
1301
1302
1303
1304
1305
1306
1307


1308
1309
1310
1311
1312
1313


1314
1315
1316
1317
1318
1319
1320
1321


1322
1323
1324
1325
1326
1327


1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343



1344
1345
1346
1347

1348
1349

1350
1351
1352
1353
1354
1355
1356
1357







+
-
-
+
+
+


+
-
-
+
+
+




+
-
-
+
+
+


+
-
-
+
+
+












+
-
-
-
+
+
+

-
+

-
+







    sqlite3_randomness(sizeof(r),r);
    sqlite3_snprintf(sizeof(zBoundary),zBoundary,
                     "--------%016llu%016llu%016llu", r[0], r[1], r[2]);
    blob_appendf(&up, "%s", zBoundary);
    zLMTime = db_text(0,
              "SELECT strftime('%%Y-%%m-%%dT%%H:%%M:%%S','now','localtime')");
    if( zLMTime ){
      blob_appendf(&up,
      blob_appendf(&up,"\r\nContent-Disposition: form-data; name=\"lmtime\"\r\n"
                       "\r\n%z\r\n%s", zLMTime, zBoundary);
          CRLF "Content-Disposition: form-data; name=\"lmtime\"" CRLF
          CRLF "%z" CRLF "%s",
          zLMTime, zBoundary);
    }
    if( g.url.user && g.url.user[0] ){
      blob_appendf(&up,
      blob_appendf(&up,"\r\nContent-Disposition: form-data; name=\"resid\"\r\n"
                       "\r\n%z\r\n%s", obscure(g.url.user), zBoundary);
          CRLF "Content-Disposition: form-data; name=\"resid\"" CRLF
          CRLF "%z" CRLF "%s",
          obscure(g.url.user), zBoundary);
    }
    zPw = g.url.passwd;
    if( zPw==0 && isDefaultUrl ) zPw = unobscure(db_get("last-sync-pw", 0));
    if( zPw && zPw[0] ){
      blob_appendf(&up,
      blob_appendf(&up,"\r\nContent-Disposition: form-data; name=\"token\"\r\n"
                       "\r\n%z\r\n%s", obscure(zPw), zBoundary);
          CRLF "Content-Disposition: form-data; name=\"token\"" CRLF
          CRLF "%z" CRLF "%s",
          obscure(zPw), zBoundary);
    }
    if( zMsg && zMsg[0] ){
      blob_appendf(&up,
      blob_appendf(&up,"\r\nContent-Disposition: form-data; name=\"msg\"\r\n"
                       "\r\n%s\r\n%s", zMsg, zBoundary);
          CRLF "Content-Disposition: form-data; name=\"msg\"" CRLF
          CRLF "%s" CRLF "%s",
          zMsg, zBoundary);
    }
    if( zFilename && blob_read_from_file(&fcontent, zFilename, ExtFILE)>0 ){
      char *zFN = mprintf("%s", file_tail(zAs ? zAs : zFilename));
      int i;
      const char *zMime = mimetype_from_name(zFN);
      for(i=0; zFN[i]; i++){
        char c = zFN[i];
        if( fossil_isalnum(c) ) continue;
        if( c=='.' ) continue;
        if( c=='-' ) continue;
        zFN[i] = '_';
      }
      blob_appendf(&up,
      blob_appendf(&up,"\r\nContent-Disposition: form-data; name=\"file\";"
                       " filename=\"%s\"\r\n", zFN);
      blob_appendf(&up,"Content-Type: %s\r\n\r\n", zMime);
        CRLF "Content-Disposition: form-data; name=\"file\";"
             " filename=\"%s\"" CRLF, zFN);
      blob_appendf(&up,"Content-Type: %s" CRLF CRLF, zMime);
      blob_append(&up, fcontent.aData, fcontent.nUsed);
      blob_appendf(&up,"\r\n%s", zBoundary);
      blob_appendf(&up,CRLF "%s", zBoundary);
    }
    blob_append(&up,"--\r\n", 4);
    blob_append(&up,"--" CRLF, CRLF_SZ+2);
    http_exchange(&up, &down, mFlags, 4, "multipart/form-data");
    blob_reset(&up);
    if( sqlite3_strglob("{\"isError\": true,*", blob_str(&down))==0 ){
      if( strstr(blob_str(&down), "not logged in")!=0 ){
        fossil_print("ERROR: username and/or password is incorrect\n");
      }else{
        fossil_print("ERROR: %s\n", blob_str(&down));