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.

aku 2014-05-28 03:55 trunk
Commit de1921bad3ce6b0a25d654b993fe3fc768139162
1 file changed +17 -1
+17 -1
--- src/export.c
+++ src/export.c
@@ -53,25 +53,41 @@
5353
zName[j] = 0;
5454
printf(" %s <%s>", zName, zUser);
5555
free(zName);
5656
return;
5757
}
58
+ /*
59
+ ** We have contact information.
60
+ ** It may or may not contain an email address.
61
+ */
5862
zContact = db_column_text(&q, 0);
5963
for(i=0; zContact[i] && zContact[i]!='>' && zContact[i]!='<'; i++){}
6064
if( zContact[i]==0 ){
65
+ /* No email address found. Take as user info if not empty */
6166
printf(" %s <%s>", zContact[0] ? zContact : zUser, zUser);
6267
db_reset(&q);
6368
return;
6469
}
6570
if( zContact[i]=='<' ){
71
+ /*
72
+ ** Found beginning of email address. Look for the end and extract
73
+ ** the part.
74
+ */
6675
zEmail = mprintf("%s", &zContact[i]);
6776
for(i=0; zEmail[i] && zEmail[i]!='>'; i++){}
6877
if( zEmail[i]=='>' ) zEmail[i+1] = 0;
6978
}else{
79
+ /*
80
+ ** Found an end marker for email, but nothing else.
81
+ */
7082
zEmail = mprintf("<%s>", zUser);
7183
}
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);
7389
for(i=j=0; zName[i]; i++){
7490
if( zName[i]!='"' ) zName[j++] = zName[i];
7591
}
7692
zName[j] = 0;
7793
printf(" %s %s", zName, zEmail);
7894
--- 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

Keyboard Shortcuts

Open search /
Next entry (timeline) j
Previous entry (timeline) k
Open focused entry Enter
Show this help ?
Toggle theme Top nav button