Fossil SCM
Improved parsing of the --port option on the "fossil server" command.
Commit
f8f2c8d2595020ea5d860f3271f37a75cd4346d652bb30c48c9037e8a5da79d5
Parent
696e14811d0d84e…
1 file changed
+25
-13
+25
-13
| --- src/main.c | ||
| +++ src/main.c | ||
| @@ -2494,15 +2494,21 @@ | ||
| 2494 | 2494 | }else{ |
| 2495 | 2495 | zInitPage = ""; |
| 2496 | 2496 | } |
| 2497 | 2497 | } |
| 2498 | 2498 | if( zPort ){ |
| 2499 | - int i; | |
| 2500 | - for(i=strlen(zPort)-1; i>=0 && zPort[i]!=':'; i--){} | |
| 2501 | - if( i>0 ){ | |
| 2502 | - zIpAddr = mprintf("%.*s", i, zPort); | |
| 2503 | - zPort += i+1; | |
| 2499 | + if( strchr(zPort,'.') || zPort[0]=='[' ){ | |
| 2500 | + int i; | |
| 2501 | + for(i=strlen(zPort)-1; i>=0 && zPort[i]!=':'; i--){} | |
| 2502 | + if( i>0 ){ | |
| 2503 | + if( zPort[0]=='[' && zPort[i-1]==']' ){ | |
| 2504 | + zIpAddr = mprintf("%.*s", i-2, zPort+1); | |
| 2505 | + }else{ | |
| 2506 | + zIpAddr = mprintf("%.*s", i, zPort); | |
| 2507 | + } | |
| 2508 | + zPort += i+1; | |
| 2509 | + } | |
| 2504 | 2510 | } |
| 2505 | 2511 | iPort = mxPort = atoi(zPort); |
| 2506 | 2512 | }else{ |
| 2507 | 2513 | iPort = db_get_int("http-port", 8080); |
| 2508 | 2514 | mxPort = iPort+100; |
| @@ -2525,16 +2531,19 @@ | ||
| 2525 | 2531 | } |
| 2526 | 2532 | } |
| 2527 | 2533 | #else |
| 2528 | 2534 | zBrowser = db_get("web-browser", "open"); |
| 2529 | 2535 | #endif |
| 2530 | - if( zIpAddr ){ | |
| 2531 | - zBrowserCmd = mprintf("%s \"http://%s:%%d/%s\" &", | |
| 2536 | + if( zIpAddr==0 ){ | |
| 2537 | + zBrowserCmd = mprintf("%s http://localhost:%%d/%s &", | |
| 2538 | + zBrowser, zInitPage); | |
| 2539 | + }else if( strchr(zIpAddr,':') ){ | |
| 2540 | + zBrowserCmd = mprintf("%s http://[%s]:%%d/%s &", | |
| 2532 | 2541 | zBrowser, zIpAddr, zInitPage); |
| 2533 | 2542 | }else{ |
| 2534 | - zBrowserCmd = mprintf("%s \"http://localhost:%%d/%s\" &", | |
| 2535 | - zBrowser, zInitPage); | |
| 2543 | + zBrowserCmd = mprintf("%s http://%s:%%d/%s &", | |
| 2544 | + zBrowser, zIpAddr, zInitPage); | |
| 2536 | 2545 | } |
| 2537 | 2546 | } |
| 2538 | 2547 | if( g.repositoryOpen ) flags |= HTTP_SERVER_HAD_REPOSITORY; |
| 2539 | 2548 | if( g.localOpen ) flags |= HTTP_SERVER_HAD_CHECKOUT; |
| 2540 | 2549 | db_close(1); |
| @@ -2565,16 +2574,19 @@ | ||
| 2565 | 2574 | process_one_web_page(zNotFound, glob_create(zFileGlob), allowRepoList); |
| 2566 | 2575 | #else |
| 2567 | 2576 | /* Win32 implementation */ |
| 2568 | 2577 | if( isUiCmd ){ |
| 2569 | 2578 | zBrowser = db_get("web-browser", "start"); |
| 2570 | - if( zIpAddr ){ | |
| 2571 | - zBrowserCmd = mprintf("%s http://%s:%%d/%s &", | |
| 2579 | + if( zIpAddr==0 ){ | |
| 2580 | + zBrowserCmd = mprintf("%s http://localhost:%%d/%s &", | |
| 2581 | + zBrowser, zInitPage); | |
| 2582 | + }else if( strchr(zIpAddr,':') ){ | |
| 2583 | + zBrowserCmd = mprintf("%s http://[%s]:%%d/%s &", | |
| 2572 | 2584 | zBrowser, zIpAddr, zInitPage); |
| 2573 | 2585 | }else{ |
| 2574 | - zBrowserCmd = mprintf("%s http://[::1]:%%d/%s &", | |
| 2575 | - zBrowser, zInitPage); | |
| 2586 | + zBrowserCmd = mprintf("%s http://%s:%%d/%s &", | |
| 2587 | + zBrowser, zIpAddr, zInitPage); | |
| 2576 | 2588 | } |
| 2577 | 2589 | } |
| 2578 | 2590 | if( g.repositoryOpen ) flags |= HTTP_SERVER_HAD_REPOSITORY; |
| 2579 | 2591 | if( g.localOpen ) flags |= HTTP_SERVER_HAD_CHECKOUT; |
| 2580 | 2592 | db_close(1); |
| 2581 | 2593 |
| --- src/main.c | |
| +++ src/main.c | |
| @@ -2494,15 +2494,21 @@ | |
| 2494 | }else{ |
| 2495 | zInitPage = ""; |
| 2496 | } |
| 2497 | } |
| 2498 | if( zPort ){ |
| 2499 | int i; |
| 2500 | for(i=strlen(zPort)-1; i>=0 && zPort[i]!=':'; i--){} |
| 2501 | if( i>0 ){ |
| 2502 | zIpAddr = mprintf("%.*s", i, zPort); |
| 2503 | zPort += i+1; |
| 2504 | } |
| 2505 | iPort = mxPort = atoi(zPort); |
| 2506 | }else{ |
| 2507 | iPort = db_get_int("http-port", 8080); |
| 2508 | mxPort = iPort+100; |
| @@ -2525,16 +2531,19 @@ | |
| 2525 | } |
| 2526 | } |
| 2527 | #else |
| 2528 | zBrowser = db_get("web-browser", "open"); |
| 2529 | #endif |
| 2530 | if( zIpAddr ){ |
| 2531 | zBrowserCmd = mprintf("%s \"http://%s:%%d/%s\" &", |
| 2532 | zBrowser, zIpAddr, zInitPage); |
| 2533 | }else{ |
| 2534 | zBrowserCmd = mprintf("%s \"http://localhost:%%d/%s\" &", |
| 2535 | zBrowser, zInitPage); |
| 2536 | } |
| 2537 | } |
| 2538 | if( g.repositoryOpen ) flags |= HTTP_SERVER_HAD_REPOSITORY; |
| 2539 | if( g.localOpen ) flags |= HTTP_SERVER_HAD_CHECKOUT; |
| 2540 | db_close(1); |
| @@ -2565,16 +2574,19 @@ | |
| 2565 | process_one_web_page(zNotFound, glob_create(zFileGlob), allowRepoList); |
| 2566 | #else |
| 2567 | /* Win32 implementation */ |
| 2568 | if( isUiCmd ){ |
| 2569 | zBrowser = db_get("web-browser", "start"); |
| 2570 | if( zIpAddr ){ |
| 2571 | zBrowserCmd = mprintf("%s http://%s:%%d/%s &", |
| 2572 | zBrowser, zIpAddr, zInitPage); |
| 2573 | }else{ |
| 2574 | zBrowserCmd = mprintf("%s http://[::1]:%%d/%s &", |
| 2575 | zBrowser, zInitPage); |
| 2576 | } |
| 2577 | } |
| 2578 | if( g.repositoryOpen ) flags |= HTTP_SERVER_HAD_REPOSITORY; |
| 2579 | if( g.localOpen ) flags |= HTTP_SERVER_HAD_CHECKOUT; |
| 2580 | db_close(1); |
| 2581 |
| --- src/main.c | |
| +++ src/main.c | |
| @@ -2494,15 +2494,21 @@ | |
| 2494 | }else{ |
| 2495 | zInitPage = ""; |
| 2496 | } |
| 2497 | } |
| 2498 | if( zPort ){ |
| 2499 | if( strchr(zPort,'.') || zPort[0]=='[' ){ |
| 2500 | int i; |
| 2501 | for(i=strlen(zPort)-1; i>=0 && zPort[i]!=':'; i--){} |
| 2502 | if( i>0 ){ |
| 2503 | if( zPort[0]=='[' && zPort[i-1]==']' ){ |
| 2504 | zIpAddr = mprintf("%.*s", i-2, zPort+1); |
| 2505 | }else{ |
| 2506 | zIpAddr = mprintf("%.*s", i, zPort); |
| 2507 | } |
| 2508 | zPort += i+1; |
| 2509 | } |
| 2510 | } |
| 2511 | iPort = mxPort = atoi(zPort); |
| 2512 | }else{ |
| 2513 | iPort = db_get_int("http-port", 8080); |
| 2514 | mxPort = iPort+100; |
| @@ -2525,16 +2531,19 @@ | |
| 2531 | } |
| 2532 | } |
| 2533 | #else |
| 2534 | zBrowser = db_get("web-browser", "open"); |
| 2535 | #endif |
| 2536 | if( zIpAddr==0 ){ |
| 2537 | zBrowserCmd = mprintf("%s http://localhost:%%d/%s &", |
| 2538 | zBrowser, zInitPage); |
| 2539 | }else if( strchr(zIpAddr,':') ){ |
| 2540 | zBrowserCmd = mprintf("%s http://[%s]:%%d/%s &", |
| 2541 | zBrowser, zIpAddr, zInitPage); |
| 2542 | }else{ |
| 2543 | zBrowserCmd = mprintf("%s http://%s:%%d/%s &", |
| 2544 | zBrowser, zIpAddr, zInitPage); |
| 2545 | } |
| 2546 | } |
| 2547 | if( g.repositoryOpen ) flags |= HTTP_SERVER_HAD_REPOSITORY; |
| 2548 | if( g.localOpen ) flags |= HTTP_SERVER_HAD_CHECKOUT; |
| 2549 | db_close(1); |
| @@ -2565,16 +2574,19 @@ | |
| 2574 | process_one_web_page(zNotFound, glob_create(zFileGlob), allowRepoList); |
| 2575 | #else |
| 2576 | /* Win32 implementation */ |
| 2577 | if( isUiCmd ){ |
| 2578 | zBrowser = db_get("web-browser", "start"); |
| 2579 | if( zIpAddr==0 ){ |
| 2580 | zBrowserCmd = mprintf("%s http://localhost:%%d/%s &", |
| 2581 | zBrowser, zInitPage); |
| 2582 | }else if( strchr(zIpAddr,':') ){ |
| 2583 | zBrowserCmd = mprintf("%s http://[%s]:%%d/%s &", |
| 2584 | zBrowser, zIpAddr, zInitPage); |
| 2585 | }else{ |
| 2586 | zBrowserCmd = mprintf("%s http://%s:%%d/%s &", |
| 2587 | zBrowser, zIpAddr, zInitPage); |
| 2588 | } |
| 2589 | } |
| 2590 | if( g.repositoryOpen ) flags |= HTTP_SERVER_HAD_REPOSITORY; |
| 2591 | if( g.localOpen ) flags |= HTTP_SERVER_HAD_CHECKOUT; |
| 2592 | db_close(1); |
| 2593 |