Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
Comment: | Add the optimized file_is_simple_pathname_nonstrict() as an alternative to file_is_simple_pathname() when parsing manifests. |
---|---|
Downloads: | Tarball | ZIP archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA3-256: |
b4aadf2cea1a4a082044a9ce11fd6765 |
User & Date: | drh 2019-09-12 17:51:42.638 |
Context
2019-09-13
| ||
09:00 | Added another link from www/fossil-v-git.wiki to rebaseharm.md. ... (check-in: 29997f803b user: wyoung tags: trunk) | |
2019-09-12
| ||
17:51 | Add the optimized file_is_simple_pathname_nonstrict() as an alternative to file_is_simple_pathname() when parsing manifests. ... (check-in: b4aadf2cea user: drh tags: trunk) | |
17:11 | Use strchr() to improve the performance of defossilize(). ... (check-in: 0aaefeaba1 user: drh tags: trunk) | |
Changes
Changes to src/file.c.
︙ | ︙ | |||
873 874 875 876 877 878 879 880 881 882 883 884 885 886 | if( z[i+2]=='/' || z[i+2]==0 ) return 0; if( z[i+2]=='.' && (z[i+3]=='/' || z[i+3]==0) ) return 0; } } } if( z[i-1]=='/' ) return 0; return 1; } /* ** If the last component of the pathname in z[0]..z[j-1] is something ** other than ".." then back it out and return true. If the last ** component is empty or if it is ".." then return false. */ | > > > > > > > > > > > > > > > > > | 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 | if( z[i+2]=='/' || z[i+2]==0 ) return 0; if( z[i+2]=='.' && (z[i+3]=='/' || z[i+3]==0) ) return 0; } } } if( z[i-1]=='/' ) return 0; return 1; } int file_is_simple_pathname_nonstrict(const char *z){ unsigned char c = (unsigned char) z[0]; if( c=='/' || c==0 ) return 0; if( c=='.' ){ if( z[1]=='/' || z[1]==0 ) return 0; if( z[1]=='.' && (z[2]=='/' || z[2]==0) ) return 0; } while( (z = strchr(z+1, '/'))!=0 ){ if( z[1]=='/' ) return 0; if( z[1]==0 ) return 0; if( z[1]=='.' ){ if( z[2]=='/' || z[2]==0 ) return 0; if( z[2]=='.' && (z[3]=='/' || z[3]==0) ) return 0; } } return 1; } /* ** If the last component of the pathname in z[0]..z[j-1] is something ** other than ".." then back it out and return true. If the last ** component is empty or if it is ".." then return false. */ |
︙ | ︙ |
Changes to src/manifest.c.
︙ | ︙ | |||
506 507 508 509 510 511 512 | int nTarget = 0, nSrc = 0; zName = next_token(&x, 0); zTarget = next_token(&x, &nTarget); zSrc = next_token(&x, &nSrc); if( zName==0 || zTarget==0 ) goto manifest_syntax_error; if( p->zAttachName!=0 ) goto manifest_syntax_error; defossilize(zName); | | | 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 | int nTarget = 0, nSrc = 0; zName = next_token(&x, 0); zTarget = next_token(&x, &nTarget); zSrc = next_token(&x, &nSrc); if( zName==0 || zTarget==0 ) goto manifest_syntax_error; if( p->zAttachName!=0 ) goto manifest_syntax_error; defossilize(zName); if( !file_is_simple_pathname_nonstrict(zName) ){ SYNTAX("invalid filename on A-card"); } defossilize(zTarget); if( !hname_validate(zTarget,nTarget) && !wiki_name_is_wellformed((const unsigned char *)zTarget) ){ SYNTAX("invalid target on A-card"); } |
︙ | ︙ | |||
604 605 606 607 608 609 610 | ** other control file. The filename and old-name are fossil-encoded. */ case 'F': { char *zName, *zPerm, *zPriorName; zName = next_token(&x,0); if( zName==0 ) SYNTAX("missing filename on F-card"); defossilize(zName); | | | | 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 | ** other control file. The filename and old-name are fossil-encoded. */ case 'F': { char *zName, *zPerm, *zPriorName; zName = next_token(&x,0); if( zName==0 ) SYNTAX("missing filename on F-card"); defossilize(zName); if( !file_is_simple_pathname_nonstrict(zName) ){ SYNTAX("F-card filename is not a simple path"); } zUuid = next_token(&x, &sz); if( p->zBaseline==0 || zUuid!=0 ){ if( !hname_validate(zUuid,sz) ){ SYNTAX("F-card hash invalid"); } } zPerm = next_token(&x,0); zPriorName = next_token(&x,0); if( zPriorName ){ defossilize(zPriorName); if( !file_is_simple_pathname_nonstrict(zPriorName) ){ SYNTAX("F-card old filename is not a simple path"); } } if( p->nFile>=p->nFileAlloc ){ p->nFileAlloc = p->nFileAlloc*2 + 10; p->aFile = fossil_realloc(p->aFile, p->nFileAlloc*sizeof(p->aFile[0]) ); |
︙ | ︙ |