Fossil SCM
Return an error instead of silently ignoring invalid input.
Commit
274e537bb064db9d72ab85200b8bb31b032f07a0
Parent
0e0e29aea0e11dd…
1 file changed
+10
-1
+10
-1
| --- src/timeline.c | ||
| +++ src/timeline.c | ||
| @@ -2038,10 +2038,17 @@ | ||
| 2038 | 2038 | && z[4]=='-' |
| 2039 | 2039 | && z[7]=='-' |
| 2040 | 2040 | && fossil_isdigit(z[0]) |
| 2041 | 2041 | && fossil_isdigit(z[5]); |
| 2042 | 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 | +} | |
| 2043 | 2050 | |
| 2044 | 2051 | /* |
| 2045 | 2052 | ** COMMAND: timeline |
| 2046 | 2053 | ** |
| 2047 | 2054 | ** Usage: %fossil timeline ?WHEN? ?CHECKIN|DATETIME? ?OPTIONS? |
| @@ -2179,19 +2186,21 @@ | ||
| 2179 | 2186 | objid = db_lget_int("checkout",0); |
| 2180 | 2187 | zDate = mprintf("(SELECT mtime FROM plink WHERE cid=%d)", objid); |
| 2181 | 2188 | }else if( name_to_uuid(&uuid, 0, "*")==0 ){ |
| 2182 | 2189 | objid = db_int(0, "SELECT rid FROM blob WHERE uuid=%B", &uuid); |
| 2183 | 2190 | zDate = mprintf("(SELECT mtime FROM event WHERE objid=%d)", objid); |
| 2184 | - }else{ | |
| 2191 | + }else if( fossil_is_julianday(zOrigin) ){ | |
| 2185 | 2192 | const char *zShift = ""; |
| 2186 | 2193 | if( mode==TIMELINE_MODE_CHILDREN || mode==TIMELINE_MODE_PARENTS ){ |
| 2187 | 2194 | fossil_fatal("cannot compute descendants or ancestors of a date"); |
| 2188 | 2195 | } |
| 2189 | 2196 | if( mode==TIMELINE_MODE_NONE ){ |
| 2190 | 2197 | if( isIsoDate(zOrigin) ) zShift = ",'+1 day'"; |
| 2191 | 2198 | } |
| 2192 | 2199 | zDate = mprintf("(SELECT julianday(%Q%s, fromLocal()))", zOrigin, zShift); |
| 2200 | + }else{ | |
| 2201 | + fossil_fatal("unknown check-in or invalid date: %s", zOrigin); | |
| 2193 | 2202 | } |
| 2194 | 2203 | |
| 2195 | 2204 | if( zFilePattern ){ |
| 2196 | 2205 | if( zType==0 ){ |
| 2197 | 2206 | /* When zFilePattern is specified and type is not specified, only show |
| 2198 | 2207 |
| --- 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 |