Fossil SCM

Return an error instead of silently ignoring invalid input.

andybradford 2016-10-04 03:55 trunk merge
Commit 274e537bb064db9d72ab85200b8bb31b032f07a0
1 file changed +10 -1
+10 -1
--- src/timeline.c
+++ src/timeline.c
@@ -2038,10 +2038,17 @@
20382038
&& z[4]=='-'
20392039
&& z[7]=='-'
20402040
&& fossil_isdigit(z[0])
20412041
&& fossil_isdigit(z[5]);
20422042
}
2043
+
2044
+/*
2045
+** Return true if the input string can be converted to a julianday.
2046
+*/
2047
+static int fossil_is_julianday(const char *zDate){
2048
+ return db_int(0, "SELECT EXISTS (SELECT julianday(%Q) AS jd WHERE jd IS NOT NULL)", zDate);
2049
+}
20432050
20442051
/*
20452052
** COMMAND: timeline
20462053
**
20472054
** Usage: %fossil timeline ?WHEN? ?CHECKIN|DATETIME? ?OPTIONS?
@@ -2179,19 +2186,21 @@
21792186
objid = db_lget_int("checkout",0);
21802187
zDate = mprintf("(SELECT mtime FROM plink WHERE cid=%d)", objid);
21812188
}else if( name_to_uuid(&uuid, 0, "*")==0 ){
21822189
objid = db_int(0, "SELECT rid FROM blob WHERE uuid=%B", &uuid);
21832190
zDate = mprintf("(SELECT mtime FROM event WHERE objid=%d)", objid);
2184
- }else{
2191
+ }else if( fossil_is_julianday(zOrigin) ){
21852192
const char *zShift = "";
21862193
if( mode==TIMELINE_MODE_CHILDREN || mode==TIMELINE_MODE_PARENTS ){
21872194
fossil_fatal("cannot compute descendants or ancestors of a date");
21882195
}
21892196
if( mode==TIMELINE_MODE_NONE ){
21902197
if( isIsoDate(zOrigin) ) zShift = ",'+1 day'";
21912198
}
21922199
zDate = mprintf("(SELECT julianday(%Q%s, fromLocal()))", zOrigin, zShift);
2200
+ }else{
2201
+ fossil_fatal("unknown check-in or invalid date: %s", zOrigin);
21932202
}
21942203
21952204
if( zFilePattern ){
21962205
if( zType==0 ){
21972206
/* When zFilePattern is specified and type is not specified, only show
21982207
--- src/timeline.c
+++ src/timeline.c
@@ -2038,10 +2038,17 @@
2038 && z[4]=='-'
2039 && z[7]=='-'
2040 && fossil_isdigit(z[0])
2041 && fossil_isdigit(z[5]);
2042 }
 
 
 
 
 
 
 
2043
2044 /*
2045 ** COMMAND: timeline
2046 **
2047 ** Usage: %fossil timeline ?WHEN? ?CHECKIN|DATETIME? ?OPTIONS?
@@ -2179,19 +2186,21 @@
2179 objid = db_lget_int("checkout",0);
2180 zDate = mprintf("(SELECT mtime FROM plink WHERE cid=%d)", objid);
2181 }else if( name_to_uuid(&uuid, 0, "*")==0 ){
2182 objid = db_int(0, "SELECT rid FROM blob WHERE uuid=%B", &uuid);
2183 zDate = mprintf("(SELECT mtime FROM event WHERE objid=%d)", objid);
2184 }else{
2185 const char *zShift = "";
2186 if( mode==TIMELINE_MODE_CHILDREN || mode==TIMELINE_MODE_PARENTS ){
2187 fossil_fatal("cannot compute descendants or ancestors of a date");
2188 }
2189 if( mode==TIMELINE_MODE_NONE ){
2190 if( isIsoDate(zOrigin) ) zShift = ",'+1 day'";
2191 }
2192 zDate = mprintf("(SELECT julianday(%Q%s, fromLocal()))", zOrigin, zShift);
 
 
2193 }
2194
2195 if( zFilePattern ){
2196 if( zType==0 ){
2197 /* When zFilePattern is specified and type is not specified, only show
2198
--- src/timeline.c
+++ src/timeline.c
@@ -2038,10 +2038,17 @@
2038 && z[4]=='-'
2039 && z[7]=='-'
2040 && fossil_isdigit(z[0])
2041 && fossil_isdigit(z[5]);
2042 }
2043
2044 /*
2045 ** Return true if the input string can be converted to a julianday.
2046 */
2047 static int fossil_is_julianday(const char *zDate){
2048 return db_int(0, "SELECT EXISTS (SELECT julianday(%Q) AS jd WHERE jd IS NOT NULL)", zDate);
2049 }
2050
2051 /*
2052 ** COMMAND: timeline
2053 **
2054 ** Usage: %fossil timeline ?WHEN? ?CHECKIN|DATETIME? ?OPTIONS?
@@ -2179,19 +2186,21 @@
2186 objid = db_lget_int("checkout",0);
2187 zDate = mprintf("(SELECT mtime FROM plink WHERE cid=%d)", objid);
2188 }else if( name_to_uuid(&uuid, 0, "*")==0 ){
2189 objid = db_int(0, "SELECT rid FROM blob WHERE uuid=%B", &uuid);
2190 zDate = mprintf("(SELECT mtime FROM event WHERE objid=%d)", objid);
2191 }else if( fossil_is_julianday(zOrigin) ){
2192 const char *zShift = "";
2193 if( mode==TIMELINE_MODE_CHILDREN || mode==TIMELINE_MODE_PARENTS ){
2194 fossil_fatal("cannot compute descendants or ancestors of a date");
2195 }
2196 if( mode==TIMELINE_MODE_NONE ){
2197 if( isIsoDate(zOrigin) ) zShift = ",'+1 day'";
2198 }
2199 zDate = mprintf("(SELECT julianday(%Q%s, fromLocal()))", zOrigin, zShift);
2200 }else{
2201 fossil_fatal("unknown check-in or invalid date: %s", zOrigin);
2202 }
2203
2204 if( zFilePattern ){
2205 if( zType==0 ){
2206 /* When zFilePattern is specified and type is not specified, only show
2207

Keyboard Shortcuts

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