Stricter enforcement of the JSON and GeoJSON standards in the Geopoly extension.
FossilOrigin-Name: c0bf3ff3af4d34ef7801c16e39128e894b00699313f4915f57aa73b57642f7fd
This commit is contained in:
+16
-11
@@ -148,15 +148,14 @@ static char geopolySkipSpace(GeoParse *p){
|
||||
static int geopolyParseNumber(GeoParse *p, GeoCoord *pVal){
|
||||
char c = geopolySkipSpace(p);
|
||||
const unsigned char *z = p->z;
|
||||
int j;
|
||||
int j = 0;
|
||||
int seenDP = 0;
|
||||
int seenE = 0;
|
||||
assert( '-' < '0' );
|
||||
if( c<='0' ){
|
||||
j = c=='-';
|
||||
if( z[j]=='0' && z[j+1]>='0' && z[j+1]<='9' ) return 0;
|
||||
if( c=='-' ){
|
||||
j = 1;
|
||||
c = z[j];
|
||||
}
|
||||
j = 1;
|
||||
if( c=='0' && z[j+1]>='0' && z[j+1]<='9' ) return 0;
|
||||
for(;; j++){
|
||||
c = z[j];
|
||||
if( c>='0' && c<='9' ) continue;
|
||||
@@ -235,13 +234,15 @@ static GeoPoly *geopolyParseJson(const unsigned char *z, int *pRc){
|
||||
}
|
||||
if( geopolySkipSpace(&s)==']'
|
||||
&& s.nVertex>=4
|
||||
&& s.a[0]==s.a[s.nVertex*2-2]
|
||||
&& s.a[1]==s.a[s.nVertex*2-1]
|
||||
&& (s.z++, geopolySkipSpace(&s)==0)
|
||||
){
|
||||
int nByte;
|
||||
GeoPoly *pOut;
|
||||
int x = (s.nVertex-1)*2;
|
||||
if( s.a[x]==s.a[0] && s.a[x+1]==s.a[1] ) s.nVertex--;
|
||||
nByte = sizeof(GeoPoly) * (s.nVertex-1)*2*sizeof(GeoCoord);
|
||||
int x = 1;
|
||||
s.nVertex--; /* Remove the redundant vertex at the end */
|
||||
nByte = sizeof(GeoPoly) * s.nVertex*2*sizeof(GeoCoord);
|
||||
pOut = sqlite3_malloc64( nByte );
|
||||
x = 1;
|
||||
if( pOut==0 ) goto parse_json_err;
|
||||
@@ -307,10 +308,14 @@ static GeoPoly *geopolyFuncParam(
|
||||
if( pRc ) *pRc = SQLITE_OK;
|
||||
return p;
|
||||
}else if( sqlite3_value_type(pVal)==SQLITE_TEXT ){
|
||||
return geopolyParseJson(sqlite3_value_text(pVal), pRc);
|
||||
const unsigned char *zJson = sqlite3_value_text(pVal);
|
||||
if( zJson==0 ){
|
||||
if( pRc ) *pRc = SQLITE_NOMEM;
|
||||
return 0;
|
||||
}
|
||||
return geopolyParseJson(zJson, pRc);
|
||||
}else{
|
||||
if( pRc ) *pRc = SQLITE_ERROR;
|
||||
if( pCtx!=0 ) sqlite3_result_error(pCtx, "not a valid polygon", -1);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
C Fix\snew\sissues\sin\sthe\sgeopoly\smodule\sdiscovered\sby\sTH3.
|
||||
D 2018-08-28T15:51:10.106
|
||||
C Stricter\senforcement\sof\sthe\sJSON\sand\sGeoJSON\sstandards\sin\sthe\sGeopoly\sextension.
|
||||
D 2018-08-28T19:23:41.917
|
||||
F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1
|
||||
F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea
|
||||
F Makefile.in d06f463c5b623a61ac27f5cb8214fca9e53a6704d34d6b8f2124e2b1b293c88f
|
||||
@@ -359,7 +359,7 @@ F ext/repair/test/checkfreelist01.test 3e8aa6aeb4007680c94a8d07b41c339aa635cc782
|
||||
F ext/repair/test/checkindex01.test 6945d0ffc0c1dc993b2ce88036b26e0f5d6fcc65da70fc9df27c2647bb358b0f
|
||||
F ext/repair/test/test.tcl 686d76d888dffd021f64260abf29a55c57b2cedfa7fc69150b42b1d6119aac3c
|
||||
F ext/rtree/README 6315c0d73ebf0ec40dedb5aa0e942bc8b54e3761
|
||||
F ext/rtree/geopoly.c 00e0cc341affcf65afd3449ce71ec45de106463e9d98b3248509e2c9499e50c8
|
||||
F ext/rtree/geopoly.c 3b27e2e493d15697b39f5c2e722f86b5c2913fa662152e34614df9cf8bc2e112
|
||||
F ext/rtree/rtree.c f3c2f1b5eea75b98d4d3dcdec2ebf2a69c036b53f2f3d196e61bf5016298255f
|
||||
F ext/rtree/rtree.h 4a690463901cb5e6127cf05eb8e642f127012fd5003830dbc974eca5802d9412
|
||||
F ext/rtree/rtree1.test 309afc04d4287542b2cd74f933296832cc681c7b014d9405cb329b62053a5349
|
||||
@@ -1758,7 +1758,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93
|
||||
F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc
|
||||
F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e
|
||||
F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0
|
||||
P 535155be584ad8c1836e6b1c62de836d9872056d39608c995221c928cb5b365d
|
||||
R 89e303590eb89c7b3ebe8848db3ad489
|
||||
P 22fff9afc2fb20906173f258aa8feae9b52acc69a0ca7baf4e914d29c4279a23
|
||||
R 9b08441f72c4a920b4c5ba9dc3c04bb3
|
||||
U drh
|
||||
Z 6ec3cd71799cdaf9a300185233e89b80
|
||||
Z d1b541ea432c030d051deb7fc1efc1dc
|
||||
|
||||
+1
-1
@@ -1 +1 @@
|
||||
22fff9afc2fb20906173f258aa8feae9b52acc69a0ca7baf4e914d29c4279a23
|
||||
c0bf3ff3af4d34ef7801c16e39128e894b00699313f4915f57aa73b57642f7fd
|
||||
Reference in New Issue
Block a user