| | @@ -328,10 +328,47 @@ |
| 328 | 328 | } |
| 329 | 329 | blob_appendf(&x, "%T", p->path); |
| 330 | 330 | (void)blob_str(&x); |
| 331 | 331 | return x.aData; |
| 332 | 332 | } |
| 333 | + |
| 334 | +/* |
| 335 | +** Construct a URL for a UrlData object that omits the |
| 336 | +** login name and password, into memory obtained from fossil_malloc() |
| 337 | +** and return a pointer to that URL text. |
| 338 | +*/ |
| 339 | +char *url_nouser(const UrlData *p){ |
| 340 | + Blob x = BLOB_INITIALIZER; |
| 341 | + if( p->isFile || p->user==0 || p->user[0]==0 ){ |
| 342 | + return fossil_strdup(p->canonical); |
| 343 | + } |
| 344 | + blob_appendf(&x, "%s://", p->protocol); |
| 345 | + blob_appendf(&x, "%T", p->name); |
| 346 | + if( p->dfltPort!=p->port ){ |
| 347 | + blob_appendf(&x, ":%d", p->port); |
| 348 | + } |
| 349 | + blob_appendf(&x, "%T", p->path); |
| 350 | + (void)blob_str(&x); |
| 351 | + return x.aData; |
| 352 | +} |
| 353 | + |
| 354 | +/* |
| 355 | +** SQL function to remove the username/password from a URL |
| 356 | +*/ |
| 357 | +void url_nouser_func( |
| 358 | + sqlite3_context *context, |
| 359 | + int argc, |
| 360 | + sqlite3_value **argv |
| 361 | +){ |
| 362 | + const char *zOrig = (const char*)sqlite3_value_text(argv[0]); |
| 363 | + UrlData x; |
| 364 | + if( zOrig==0 ) return; |
| 365 | + memset(&x, 0, sizeof(x)); |
| 366 | + url_parse_local(zOrig, URL_OMIT_USER, &x); |
| 367 | + sqlite3_result_text(context, x.canonical, -1, SQLITE_TRANSIENT); |
| 368 | + url_unparse(&x); |
| 369 | +} |
| 333 | 370 | |
| 334 | 371 | /* |
| 335 | 372 | ** Reclaim malloced memory from a UrlData object |
| 336 | 373 | */ |
| 337 | 374 | void url_unparse(UrlData *p){ |
| 338 | 375 | |