Fossil SCM
Fixed an off-by-one error in print_person(). The original code extracted the leading '<' of the email address as part of the user name, putting an unmatched '<' into the git dump file, and breaking fast_import. This bug was only triggered by the user's contact information actually containing an email address.
Commit
de1921bad3ce6b0a25d654b993fe3fc768139162
Parent
6a4127f3ed373f5…
1 file changed
+17
-1
+17
-1
| --- src/export.c | ||
| +++ src/export.c | ||
| @@ -53,25 +53,41 @@ | ||
| 53 | 53 | zName[j] = 0; |
| 54 | 54 | printf(" %s <%s>", zName, zUser); |
| 55 | 55 | free(zName); |
| 56 | 56 | return; |
| 57 | 57 | } |
| 58 | + /* | |
| 59 | + ** We have contact information. | |
| 60 | + ** It may or may not contain an email address. | |
| 61 | + */ | |
| 58 | 62 | zContact = db_column_text(&q, 0); |
| 59 | 63 | for(i=0; zContact[i] && zContact[i]!='>' && zContact[i]!='<'; i++){} |
| 60 | 64 | if( zContact[i]==0 ){ |
| 65 | + /* No email address found. Take as user info if not empty */ | |
| 61 | 66 | printf(" %s <%s>", zContact[0] ? zContact : zUser, zUser); |
| 62 | 67 | db_reset(&q); |
| 63 | 68 | return; |
| 64 | 69 | } |
| 65 | 70 | if( zContact[i]=='<' ){ |
| 71 | + /* | |
| 72 | + ** Found beginning of email address. Look for the end and extract | |
| 73 | + ** the part. | |
| 74 | + */ | |
| 66 | 75 | zEmail = mprintf("%s", &zContact[i]); |
| 67 | 76 | for(i=0; zEmail[i] && zEmail[i]!='>'; i++){} |
| 68 | 77 | if( zEmail[i]=='>' ) zEmail[i+1] = 0; |
| 69 | 78 | }else{ |
| 79 | + /* | |
| 80 | + ** Found an end marker for email, but nothing else. | |
| 81 | + */ | |
| 70 | 82 | zEmail = mprintf("<%s>", zUser); |
| 71 | 83 | } |
| 72 | - zName = mprintf("%.*s", i, zContact); | |
| 84 | + /* | |
| 85 | + ** Here zContact[i] either '<' or '>'. Extract the string _before_ | |
| 86 | + ** either as user name. | |
| 87 | + */ | |
| 88 | + zName = mprintf("%.*s", i-1, zContact); | |
| 73 | 89 | for(i=j=0; zName[i]; i++){ |
| 74 | 90 | if( zName[i]!='"' ) zName[j++] = zName[i]; |
| 75 | 91 | } |
| 76 | 92 | zName[j] = 0; |
| 77 | 93 | printf(" %s %s", zName, zEmail); |
| 78 | 94 |
| --- src/export.c | |
| +++ src/export.c | |
| @@ -53,25 +53,41 @@ | |
| 53 | zName[j] = 0; |
| 54 | printf(" %s <%s>", zName, zUser); |
| 55 | free(zName); |
| 56 | return; |
| 57 | } |
| 58 | zContact = db_column_text(&q, 0); |
| 59 | for(i=0; zContact[i] && zContact[i]!='>' && zContact[i]!='<'; i++){} |
| 60 | if( zContact[i]==0 ){ |
| 61 | printf(" %s <%s>", zContact[0] ? zContact : zUser, zUser); |
| 62 | db_reset(&q); |
| 63 | return; |
| 64 | } |
| 65 | if( zContact[i]=='<' ){ |
| 66 | zEmail = mprintf("%s", &zContact[i]); |
| 67 | for(i=0; zEmail[i] && zEmail[i]!='>'; i++){} |
| 68 | if( zEmail[i]=='>' ) zEmail[i+1] = 0; |
| 69 | }else{ |
| 70 | zEmail = mprintf("<%s>", zUser); |
| 71 | } |
| 72 | zName = mprintf("%.*s", i, zContact); |
| 73 | for(i=j=0; zName[i]; i++){ |
| 74 | if( zName[i]!='"' ) zName[j++] = zName[i]; |
| 75 | } |
| 76 | zName[j] = 0; |
| 77 | printf(" %s %s", zName, zEmail); |
| 78 |
| --- src/export.c | |
| +++ src/export.c | |
| @@ -53,25 +53,41 @@ | |
| 53 | zName[j] = 0; |
| 54 | printf(" %s <%s>", zName, zUser); |
| 55 | free(zName); |
| 56 | return; |
| 57 | } |
| 58 | /* |
| 59 | ** We have contact information. |
| 60 | ** It may or may not contain an email address. |
| 61 | */ |
| 62 | zContact = db_column_text(&q, 0); |
| 63 | for(i=0; zContact[i] && zContact[i]!='>' && zContact[i]!='<'; i++){} |
| 64 | if( zContact[i]==0 ){ |
| 65 | /* No email address found. Take as user info if not empty */ |
| 66 | printf(" %s <%s>", zContact[0] ? zContact : zUser, zUser); |
| 67 | db_reset(&q); |
| 68 | return; |
| 69 | } |
| 70 | if( zContact[i]=='<' ){ |
| 71 | /* |
| 72 | ** Found beginning of email address. Look for the end and extract |
| 73 | ** the part. |
| 74 | */ |
| 75 | zEmail = mprintf("%s", &zContact[i]); |
| 76 | for(i=0; zEmail[i] && zEmail[i]!='>'; i++){} |
| 77 | if( zEmail[i]=='>' ) zEmail[i+1] = 0; |
| 78 | }else{ |
| 79 | /* |
| 80 | ** Found an end marker for email, but nothing else. |
| 81 | */ |
| 82 | zEmail = mprintf("<%s>", zUser); |
| 83 | } |
| 84 | /* |
| 85 | ** Here zContact[i] either '<' or '>'. Extract the string _before_ |
| 86 | ** either as user name. |
| 87 | */ |
| 88 | zName = mprintf("%.*s", i-1, zContact); |
| 89 | for(i=j=0; zName[i]; i++){ |
| 90 | if( zName[i]!='"' ) zName[j++] = zName[i]; |
| 91 | } |
| 92 | zName[j] = 0; |
| 93 | printf(" %s %s", zName, zEmail); |
| 94 |