Fossil SCM
Use the same algorithm for event-id's for UUID's as in other UI locations: Make sure that the UUID contains at least a single lower-case digit, with a minimum of length 10.
Commit
734d4299401357a56768106350c6b766a1441524
Parent
2e51be8ec2df7cd…
2 files changed
+5
-4
+2
-24
+5
-4
| --- src/printf.c | ||
| +++ src/printf.c | ||
| @@ -608,22 +608,23 @@ | ||
| 608 | 608 | case etROOT: { |
| 609 | 609 | bufpt = g.zTop ? g.zTop : ""; |
| 610 | 610 | length = (int)strlen(bufpt); |
| 611 | 611 | break; |
| 612 | 612 | } |
| 613 | - case etSTRINGID: { | |
| 614 | - precision = 16; | |
| 615 | - /* Fall through */ | |
| 616 | - } | |
| 613 | + case etSTRINGID: | |
| 617 | 614 | case etSTRING: |
| 618 | 615 | case etDYNSTRING: { |
| 619 | 616 | int limit = flag_alternateform ? va_arg(ap,int) : -1; |
| 620 | 617 | bufpt = va_arg(ap,char*); |
| 621 | 618 | if( bufpt==0 ){ |
| 622 | 619 | bufpt = ""; |
| 623 | 620 | }else if( xtype==etDYNSTRING ){ |
| 624 | 621 | zExtra = bufpt; |
| 622 | + }else if( xtype==etSTRINGID ){ | |
| 623 | + precision = 0; | |
| 624 | + while( fossil_isdigit(bufpt[precision++]) ){}; | |
| 625 | + if( precision<10 ) precision=10; | |
| 625 | 626 | } |
| 626 | 627 | length = StrNLen32(bufpt, limit); |
| 627 | 628 | if( precision>=0 && precision<length ) length = precision; |
| 628 | 629 | break; |
| 629 | 630 | } |
| 630 | 631 |
| --- src/printf.c | |
| +++ src/printf.c | |
| @@ -608,22 +608,23 @@ | |
| 608 | case etROOT: { |
| 609 | bufpt = g.zTop ? g.zTop : ""; |
| 610 | length = (int)strlen(bufpt); |
| 611 | break; |
| 612 | } |
| 613 | case etSTRINGID: { |
| 614 | precision = 16; |
| 615 | /* Fall through */ |
| 616 | } |
| 617 | case etSTRING: |
| 618 | case etDYNSTRING: { |
| 619 | int limit = flag_alternateform ? va_arg(ap,int) : -1; |
| 620 | bufpt = va_arg(ap,char*); |
| 621 | if( bufpt==0 ){ |
| 622 | bufpt = ""; |
| 623 | }else if( xtype==etDYNSTRING ){ |
| 624 | zExtra = bufpt; |
| 625 | } |
| 626 | length = StrNLen32(bufpt, limit); |
| 627 | if( precision>=0 && precision<length ) length = precision; |
| 628 | break; |
| 629 | } |
| 630 |
| --- src/printf.c | |
| +++ src/printf.c | |
| @@ -608,22 +608,23 @@ | |
| 608 | case etROOT: { |
| 609 | bufpt = g.zTop ? g.zTop : ""; |
| 610 | length = (int)strlen(bufpt); |
| 611 | break; |
| 612 | } |
| 613 | case etSTRINGID: |
| 614 | case etSTRING: |
| 615 | case etDYNSTRING: { |
| 616 | int limit = flag_alternateform ? va_arg(ap,int) : -1; |
| 617 | bufpt = va_arg(ap,char*); |
| 618 | if( bufpt==0 ){ |
| 619 | bufpt = ""; |
| 620 | }else if( xtype==etDYNSTRING ){ |
| 621 | zExtra = bufpt; |
| 622 | }else if( xtype==etSTRINGID ){ |
| 623 | precision = 0; |
| 624 | while( fossil_isdigit(bufpt[precision++]) ){}; |
| 625 | if( precision<10 ) precision=10; |
| 626 | } |
| 627 | length = StrNLen32(bufpt, limit); |
| 628 | if( precision>=0 && precision<length ) length = precision; |
| 629 | break; |
| 630 | } |
| 631 |
+2
-24
| --- src/timeline.c | ||
| +++ src/timeline.c | ||
| @@ -20,41 +20,19 @@ | ||
| 20 | 20 | */ |
| 21 | 21 | #include "config.h" |
| 22 | 22 | #include <string.h> |
| 23 | 23 | #include <time.h> |
| 24 | 24 | #include "timeline.h" |
| 25 | - | |
| 26 | -/* | |
| 27 | -** Shorten a UUID so that is the minimum length needed to contain | |
| 28 | -** at least one digit in the range 'a'..'f'. The minimum length is 10. | |
| 29 | -*/ | |
| 30 | -static void shorten_uuid(char *zDest, const char *zSrc){ | |
| 31 | - int i; | |
| 32 | - for(i=0; i<10 && zSrc[i]<='9'; i++){} | |
| 33 | - memcpy(zDest, zSrc, 10); | |
| 34 | - if( i==10 && zSrc[i] ){ | |
| 35 | - do{ | |
| 36 | - zDest[i] = zSrc[i]; | |
| 37 | - i++; | |
| 38 | - }while( zSrc[i-1]<='9' ); | |
| 39 | - }else{ | |
| 40 | - i = 10; | |
| 41 | - } | |
| 42 | - zDest[i] = 0; | |
| 43 | -} | |
| 44 | - | |
| 45 | 25 | |
| 46 | 26 | /* |
| 47 | 27 | ** Generate a hyperlink to a version. |
| 48 | 28 | */ |
| 49 | 29 | void hyperlink_to_uuid(const char *zUuid){ |
| 50 | - char z[UUID_SIZE+1]; | |
| 51 | - shorten_uuid(z, zUuid); | |
| 52 | 30 | if( g.perm.Hyperlink ){ |
| 53 | - @ %z(xhref("class='timelineHistLink'","%R/info/%s",zUuid))[%s(z)]</a> | |
| 31 | + @ %z(xhref("class='timelineHistLink'","%R/info/%s",zUuid))[%S(zUuid)]</a> | |
| 54 | 32 | }else{ |
| 55 | - @ <span class="timelineHistDsp">[%s(z)]</span> | |
| 33 | + @ <span class="timelineHistDsp">[%S(zUuid)]</span> | |
| 56 | 34 | } |
| 57 | 35 | } |
| 58 | 36 | |
| 59 | 37 | /* |
| 60 | 38 | ** Generate a hyperlink to a date & time. |
| 61 | 39 |
| --- src/timeline.c | |
| +++ src/timeline.c | |
| @@ -20,41 +20,19 @@ | |
| 20 | */ |
| 21 | #include "config.h" |
| 22 | #include <string.h> |
| 23 | #include <time.h> |
| 24 | #include "timeline.h" |
| 25 | |
| 26 | /* |
| 27 | ** Shorten a UUID so that is the minimum length needed to contain |
| 28 | ** at least one digit in the range 'a'..'f'. The minimum length is 10. |
| 29 | */ |
| 30 | static void shorten_uuid(char *zDest, const char *zSrc){ |
| 31 | int i; |
| 32 | for(i=0; i<10 && zSrc[i]<='9'; i++){} |
| 33 | memcpy(zDest, zSrc, 10); |
| 34 | if( i==10 && zSrc[i] ){ |
| 35 | do{ |
| 36 | zDest[i] = zSrc[i]; |
| 37 | i++; |
| 38 | }while( zSrc[i-1]<='9' ); |
| 39 | }else{ |
| 40 | i = 10; |
| 41 | } |
| 42 | zDest[i] = 0; |
| 43 | } |
| 44 | |
| 45 | |
| 46 | /* |
| 47 | ** Generate a hyperlink to a version. |
| 48 | */ |
| 49 | void hyperlink_to_uuid(const char *zUuid){ |
| 50 | char z[UUID_SIZE+1]; |
| 51 | shorten_uuid(z, zUuid); |
| 52 | if( g.perm.Hyperlink ){ |
| 53 | @ %z(xhref("class='timelineHistLink'","%R/info/%s",zUuid))[%s(z)]</a> |
| 54 | }else{ |
| 55 | @ <span class="timelineHistDsp">[%s(z)]</span> |
| 56 | } |
| 57 | } |
| 58 | |
| 59 | /* |
| 60 | ** Generate a hyperlink to a date & time. |
| 61 |
| --- src/timeline.c | |
| +++ src/timeline.c | |
| @@ -20,41 +20,19 @@ | |
| 20 | */ |
| 21 | #include "config.h" |
| 22 | #include <string.h> |
| 23 | #include <time.h> |
| 24 | #include "timeline.h" |
| 25 | |
| 26 | /* |
| 27 | ** Generate a hyperlink to a version. |
| 28 | */ |
| 29 | void hyperlink_to_uuid(const char *zUuid){ |
| 30 | if( g.perm.Hyperlink ){ |
| 31 | @ %z(xhref("class='timelineHistLink'","%R/info/%s",zUuid))[%S(zUuid)]</a> |
| 32 | }else{ |
| 33 | @ <span class="timelineHistDsp">[%S(zUuid)]</span> |
| 34 | } |
| 35 | } |
| 36 | |
| 37 | /* |
| 38 | ** Generate a hyperlink to a date & time. |
| 39 |