Skip to content

Commit

Permalink
Merge pull request #429 from mapbox/bom2
Browse files Browse the repository at this point in the history
Ignore UTF-8 byte order mark if present
  • Loading branch information
e-n-f authored Jun 29, 2017
2 parents 240ccbd + dd0a135 commit bd845ac
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 4 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
## 1.19.2
* Ignore UTF-8 byte order mark if present

## 1.19.1

* Add an option to increase maxzoom if features are still being dropped
Expand Down
20 changes: 18 additions & 2 deletions jsonpull/jsonpull.c
Original file line number Diff line number Diff line change
Expand Up @@ -36,14 +36,14 @@ json_pull *json_begin(ssize_t (*read)(struct json_pull *, char *buffer, size_t n

static inline int peek(json_pull *j) {
if (j->buffer_head < j->buffer_tail) {
return j->buffer[j->buffer_head];
return (unsigned char) j->buffer[j->buffer_head];
} else {
j->buffer_head = 0;
j->buffer_tail = j->read(j, j->buffer, BUFFER);
if (j->buffer_head >= j->buffer_tail) {
return EOF;
}
return j->buffer[j->buffer_head];
return (unsigned char) j->buffer[j->buffer_head];
}
}

Expand Down Expand Up @@ -295,6 +295,22 @@ json_object *json_read_separators(json_pull *j, json_separator_callback cb, void

return NULL;
}

// Byte-order mark
if (c == 0xEF) {
int c2 = peek(j);
if (c2 == 0xBB) {
c2 = read_wrap(j);
c2 = peek(j);
if (c2 == 0xBF) {
c2 = read_wrap(j);
c = ' ';
continue;
}
}
j->error = "Corrupt byte-order mark found";
return NULL;
}
} while (c == ' ' || c == '\t' || c == '\r' || c == '\n' || c == 0x1E);

/////////////////////////// Arrays
Expand Down
2 changes: 1 addition & 1 deletion tests/islands/in.json
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
{ "type": "Feature", "properties": { "adm1_code": "FSM-4943", "OBJECTID_1": 6464, "diss_me": 4943, "adm1_cod_1": "FSM-4943", "iso_3166_2": "FM-YAP", "wikipedia": "http:\/\/en.wikipedia.org\/wiki\/Yap_State", "iso_a2": "FM", "adm0_sr": 5, "name": "Yap", "name_alt": null, "name_local": null, "type": null, "type_en": null, "code_local": null, "code_hasc": "FM.YA", "note": null, "hasc_maybe": null, "region": null, "region_cod": null, "provnum_ne": 0, "gadm_level": 0, "check_me": 0, "scalerank": 10, "datarank": 10, "abbrev": null, "postal": null, "area_sqkm": 0, "sameascity": -99, "labelrank": 20, "featurecla": "Admin-1 scale rank", "name_len": 3, "mapcolor9": 4, "mapcolor13": 13, "fips": "FM04", "fips_alt": null, "woe_id": 2345343, "woe_label": "Yap, FM, Federated States of Micronesia", "woe_name": "Yap", "latitude": 9.5810099999999991, "longitude": 138.114, "sov_a3": "FSM", "adm0_a3": "FSM", "adm0_label": 5, "admin": "Federated States of Micronesia", "geonunit": "Federated States of Micronesia", "gu_a3": "FSM", "gn_id": 2081175, "gn_name": "State of Yap", "gns_id": -3741502, "gns_name": "Yap, State of", "gn_level": 1, "gn_region": null, "gn_a1_code": "FM.04", "region_sub": null, "sub_code": null, "gns_level": 1, "gns_lang": null, "gns_adm1": "FM04", "gns_region": null }, "geometry": { "type": "MultiPolygon", "coordinates": [ [ [ [ 143.920339389000134, 7.354966539000131 ], [ 143.915456576000139, 7.344142971000124 ], [ 143.917979363000057, 7.354803778000161 ], [ 143.917491082000055, 7.359930731000176 ], [ 143.920339389000134, 7.354966539000131 ] ] ], [ [ [ 143.843028191, 7.370550848000121 ], [ 143.834971550000063, 7.367824611000145 ], [ 143.839040561000019, 7.377427476000122 ], [ 143.843841993000211, 7.377468166000114 ], [ 143.843028191, 7.370550848000121 ] ] ], [ [ [ 143.858409050000233, 7.37791575700011 ], [ 143.859385613000228, 7.37213776200015 ], [ 143.855642123000194, 7.373846747000158 ], [ 143.858409050000233, 7.37791575700011 ] ] ], [ [ [ 143.918060743000041, 7.373236395000106 ], [ 143.916107618000098, 7.366563218000138 ], [ 143.914642774000214, 7.367295640000165 ], [ 143.908132358000245, 7.370754299000083 ], [ 143.910411004, 7.379461981000148 ], [ 143.918060743000041, 7.373236395000106 ] ] ], [ [ [ 138.184255405000187, 9.544378973000136 ], [ 138.197520379, 9.539007880000085 ], [ 138.219004754000053, 9.548570054000081 ], [ 138.214121941000172, 9.537054755000142 ], [ 138.202403191000172, 9.521185614000117 ], [ 138.188731316000059, 9.506822007000139 ], [ 138.177989129000053, 9.500189520000077 ], [ 138.164073113000228, 9.504828192000105 ], [ 138.15658613399998, 9.525783596000139 ], [ 138.143809441000059, 9.521307684000178 ], [ 138.134450717000192, 9.511867580000157 ], [ 138.079844597000061, 9.425441799000069 ], [ 138.068125847000061, 9.412054755000071 ], [ 138.063812696000156, 9.436102606000105 ], [ 138.073008660000056, 9.470404364000075 ], [ 138.089121941000116, 9.501166083000143 ], [ 138.105967644000117, 9.514471747000158 ], [ 138.112966342000192, 9.521470445000148 ], [ 138.121267123000081, 9.55487702000012 ], [ 138.126231316, 9.565985419000143 ], [ 138.141123894000174, 9.5743675800001 ], [ 138.147227410000056, 9.567368882000125 ], [ 138.150075717000192, 9.541164455000086 ], [ 138.151866082000055, 9.550848700000145 ], [ 138.154958530000073, 9.560736395000148 ], [ 138.159190300000063, 9.569525458000129 ], [ 138.16439863399998, 9.575873114000146 ], [ 138.173187696000156, 9.582342841000155 ], [ 138.184906446000042, 9.588812567000062 ], [ 138.193614129000053, 9.588853257000054 ], [ 138.19239342500012, 9.575873114000146 ], [ 138.181651238000114, 9.558742580000114 ], [ 138.184255405000187, 9.544378973000136 ] ] ], [ [ [ 140.524668816000059, 9.764471747000115 ], [ 140.515391472, 9.761175848000079 ], [ 140.51417076900006, 9.76780833500014 ], [ 140.521739129000053, 9.774725653000132 ], [ 140.531260613000228, 9.775580145000134 ], [ 140.532888217000078, 9.771918036000088 ], [ 140.524668816000059, 9.764471747000115 ] ] ] ] } },
{ "type": "Feature", "properties": { "adm1_code": "FSM-4943", "OBJECTID_1": 6464, "diss_me": 4943, "adm1_cod_1": "FSM-4943", "iso_3166_2": "FM-YAP", "wikipedia": "http:\/\/en.wikipedia.org\/wiki\/Yap_State", "iso_a2": "FM", "adm0_sr": 5, "name": "Yap", "name_alt": null, "name_local": null, "type": null, "type_en": null, "code_local": null, "code_hasc": "FM.YA", "note": null, "hasc_maybe": null, "region": null, "region_cod": null, "provnum_ne": 0, "gadm_level": 0, "check_me": 0, "scalerank": 10, "datarank": 10, "abbrev": null, "postal": null, "area_sqkm": 0, "sameascity": -99, "labelrank": 20, "featurecla": "Admin-1 scale rank", "name_len": 3, "mapcolor9": 4, "mapcolor13": 13, "fips": "FM04", "fips_alt": null, "woe_id": 2345343, "woe_label": "Yap, FM, Federated States of Micronesia", "woe_name": "Yap", "latitude": 9.5810099999999991, "longitude": 138.114, "sov_a3": "FSM", "adm0_a3": "FSM", "adm0_label": 5, "admin": "Federated States of Micronesia", "geonunit": "Federated States of Micronesia", "gu_a3": "FSM", "gn_id": 2081175, "gn_name": "State of Yap", "gns_id": -3741502, "gns_name": "Yap, State of", "gn_level": 1, "gn_region": null, "gn_a1_code": "FM.04", "region_sub": null, "sub_code": null, "gns_level": 1, "gns_lang": null, "gns_adm1": "FM04", "gns_region": null }, "geometry": { "type": "MultiPolygon", "coordinates": [ [ [ [ 143.920339389000134, 7.354966539000131 ], [ 143.915456576000139, 7.344142971000124 ], [ 143.917979363000057, 7.354803778000161 ], [ 143.917491082000055, 7.359930731000176 ], [ 143.920339389000134, 7.354966539000131 ] ] ], [ [ [ 143.843028191, 7.370550848000121 ], [ 143.834971550000063, 7.367824611000145 ], [ 143.839040561000019, 7.377427476000122 ], [ 143.843841993000211, 7.377468166000114 ], [ 143.843028191, 7.370550848000121 ] ] ], [ [ [ 143.858409050000233, 7.37791575700011 ], [ 143.859385613000228, 7.37213776200015 ], [ 143.855642123000194, 7.373846747000158 ], [ 143.858409050000233, 7.37791575700011 ] ] ], [ [ [ 143.918060743000041, 7.373236395000106 ], [ 143.916107618000098, 7.366563218000138 ], [ 143.914642774000214, 7.367295640000165 ], [ 143.908132358000245, 7.370754299000083 ], [ 143.910411004, 7.379461981000148 ], [ 143.918060743000041, 7.373236395000106 ] ] ], [ [ [ 138.184255405000187, 9.544378973000136 ], [ 138.197520379, 9.539007880000085 ], [ 138.219004754000053, 9.548570054000081 ], [ 138.214121941000172, 9.537054755000142 ], [ 138.202403191000172, 9.521185614000117 ], [ 138.188731316000059, 9.506822007000139 ], [ 138.177989129000053, 9.500189520000077 ], [ 138.164073113000228, 9.504828192000105 ], [ 138.15658613399998, 9.525783596000139 ], [ 138.143809441000059, 9.521307684000178 ], [ 138.134450717000192, 9.511867580000157 ], [ 138.079844597000061, 9.425441799000069 ], [ 138.068125847000061, 9.412054755000071 ], [ 138.063812696000156, 9.436102606000105 ], [ 138.073008660000056, 9.470404364000075 ], [ 138.089121941000116, 9.501166083000143 ], [ 138.105967644000117, 9.514471747000158 ], [ 138.112966342000192, 9.521470445000148 ], [ 138.121267123000081, 9.55487702000012 ], [ 138.126231316, 9.565985419000143 ], [ 138.141123894000174, 9.5743675800001 ], [ 138.147227410000056, 9.567368882000125 ], [ 138.150075717000192, 9.541164455000086 ], [ 138.151866082000055, 9.550848700000145 ], [ 138.154958530000073, 9.560736395000148 ], [ 138.159190300000063, 9.569525458000129 ], [ 138.16439863399998, 9.575873114000146 ], [ 138.173187696000156, 9.582342841000155 ], [ 138.184906446000042, 9.588812567000062 ], [ 138.193614129000053, 9.588853257000054 ], [ 138.19239342500012, 9.575873114000146 ], [ 138.181651238000114, 9.558742580000114 ], [ 138.184255405000187, 9.544378973000136 ] ] ], [ [ [ 140.524668816000059, 9.764471747000115 ], [ 140.515391472, 9.761175848000079 ], [ 140.51417076900006, 9.76780833500014 ], [ 140.521739129000053, 9.774725653000132 ], [ 140.531260613000228, 9.775580145000134 ], [ 140.532888217000078, 9.771918036000088 ], [ 140.524668816000059, 9.764471747000115 ] ] ] ] } },
{ "type": "Feature", "properties": { "adm1_code": "KIR+99?", "OBJECTID_1": 3643, "diss_me": 10097, "adm1_cod_1": "KIR+99?", "iso_3166_2": "KI-", "wikipedia": null, "iso_a2": "KI", "adm0_sr": 5, "name": null, "name_alt": null, "name_local": null, "type": null, "type_en": null, "code_local": null, "code_hasc": "-99", "note": "KIR-99 (Kiribati minor island)", "hasc_maybe": null, "region": null, "region_cod": null, "provnum_ne": 0, "gadm_level": 0, "check_me": 0, "scalerank": 11, "datarank": 11, "abbrev": null, "postal": null, "area_sqkm": 0, "sameascity": -99, "labelrank": 20, "featurecla": "Admin-1 minor island", "name_len": 0, "mapcolor9": 6, "mapcolor13": 12, "fips": null, "fips_alt": null, "woe_id": -99, "woe_label": null, "woe_name": null, "latitude": -4.6896699999999996, "longitude": -174.511, "sov_a3": "KIR", "adm0_a3": "KIR", "adm0_label": 7, "admin": "Kiribati", "geonunit": "Kiribati", "gu_a3": "KIR", "gn_id": 0, "gn_name": null, "gns_id": 0, "gns_name": null, "gn_level": 0, "gn_region": null, "gn_a1_code": "KI.", "region_sub": null, "sub_code": null, "gns_level": 0, "gns_lang": null, "gns_adm1": null, "gns_region": null }, "geometry": { "type": "MultiPolygon", "coordinates": [ [ [ [ -150.231231248999904, -10.007582289999874 ], [ -150.236154751999948, -10.00986093499985 ], [ -150.24282792899993, -10.005547783999845 ], [ -150.241769985999952, -10.000339450999846 ], [ -150.235585089999887, -10.001234632999839 ], [ -150.231231248999904, -10.007582289999874 ] ] ], [ [ [ -150.206410285999937, -9.955336195999863 ], [ -150.208159959999932, -9.960056247999873 ], [ -150.207793748999904, -9.931817315999893 ], [ -150.20754960799988, -9.932142835999827 ], [ -150.206410285999937, -9.955336195999863 ] ] ], [ [ [ -150.211537238999881, -9.919203382999825 ], [ -150.208526170999846, -9.927260023999864 ], [ -150.212676561999899, -9.923109632999825 ], [ -150.216013149999924, -9.914971612999892 ], [ -150.211537238999881, -9.919203382999825 ] ] ], [ [ [ -155.906809048999946, -5.611993096999825 ], [ -155.899322068999879, -5.616794528999904 ], [ -155.879628058999913, -5.609470309999892 ], [ -155.865061001999891, -5.615166924999883 ], [ -155.859811977999925, -5.625095309999878 ], [ -155.867990688999896, -5.630303643999881 ], [ -155.906442837999919, -5.635349216999899 ], [ -155.92247473899991, -5.629978122999859 ], [ -155.933461066999882, -5.609144789999874 ], [ -155.923898891999897, -5.608086846999825 ], [ -155.914987758999928, -5.609063408999887 ], [ -155.906809048999946, -5.611993096999825 ] ] ], [ [ [ -174.500681118999864, -4.694268487999977 ], [ -174.501535610999866, -4.697360934999963 ], [ -174.512155727999925, -4.691989841999913 ], [ -174.521555141999926, -4.68385182099982 ], [ -174.516713019999855, -4.68425872199991 ], [ -174.506418423999946, -4.689141533999887 ], [ -174.500681118999864, -4.694268487999977 ] ] ], [ [ [ -174.527902798999889, -4.683526299999883 ], [ -174.527658657999922, -4.68385182099982 ], [ -174.533884243999893, -4.680759373 ], [ -174.541737433999856, -4.672784112999864 ], [ -174.540109829999949, -4.672051690999837 ], [ -174.535878058999913, -4.677504164999959 ], [ -174.529286261999943, -4.682712497999873 ], [ -174.527902798999889, -4.683526299999883 ] ] ], [ [ [ -174.501535610999866, -4.687676690999822 ], [ -174.500843878999945, -4.69109465899983 ], [ -174.513986782999893, -4.676202080999872 ], [ -174.528269008999871, -4.667413018999909 ], [ -174.538075324999909, -4.665215752999828 ], [ -174.543405727999868, -4.660251559999864 ], [ -174.538400844999927, -4.656508070999834 ], [ -174.52440344999988, -4.664483330999971 ], [ -174.501535610999866, -4.687676690999822 ] ] ], [ [ [ -171.236520962999862, -4.468519790000016 ], [ -171.249582485999952, -4.469821872999844 ], [ -171.259632941999939, -4.465264580999886 ], [ -171.264027472999913, -4.456312757999868 ], [ -171.259958462999947, -4.444105726999894 ], [ -171.259917772999955, -4.444105726999894 ], [ -171.244984503999916, -4.441338799999841 ], [ -171.233876105999883, -4.448988539999945 ], [ -171.230051235999866, -4.46054452899989 ], [ -171.236520962999862, -4.468519790000016 ] ] ], [ [ [ -171.087269660999908, -3.143161716999856 ], [ -171.092477993999921, -3.145440362999921 ], [ -171.093576626999948, -3.131442966999956 ], [ -171.090036587999862, -3.120863539999917 ], [ -171.08543860599994, -3.111260674999841 ], [ -171.083119269999884, -3.129978122999901 ], [ -171.087269660999908, -3.143161716999856 ] ] ], [ [ [ 174.237478061000132, -0.526543877999899 ], [ 174.245290561000076, -0.529310804999952 ], [ 174.245778842000249, -0.531182549999841 ], [ 174.240896030000187, -0.528252862999821 ], [ 174.236745639000077, -0.529636325999974 ], [ 174.234141472000175, -0.529717705999957 ], [ 174.237478061000132, -0.526543877999899 ] ] ], [ [ [ 173.550466342000192, 0.173895575000103 ], [ 173.542002800000176, 0.171576239000046 ], [ 173.537282748000251, 0.17194245000006 ], [ 173.529714388999906, 0.174343166000099 ], [ 173.525075716999964, 0.178778387000165 ], [ 173.534434441000172, 0.183579820000148 ], [ 173.550466342000192, 0.18105703300013 ], [ 173.550466342000192, 0.173895575000103 ] ] ], [ [ [ 173.413910352000215, 0.2071800800001 ], [ 173.391449415000096, 0.19277578300013 ], [ 173.383148633999923, 0.199571031000147 ], [ 173.377614780000187, 0.214748440000136 ], [ 173.37973066500021, 0.223334052000055 ], [ 173.389170769000231, 0.225775458000086 ], [ 173.398529493000268, 0.223089911000116 ], [ 173.414073113000228, 0.211859442000105 ], [ 173.413910352000215, 0.2071800800001 ] ] ], [ [ [ 173.372894727000158, 0.242092190000108 ], [ 173.368337436000132, 0.2378604190001 ], [ 173.348155144, 0.254380601000079 ], [ 173.347585483000074, 0.263291734000106 ], [ 173.354828321000156, 0.268296617000061 ], [ 173.364349806000263, 0.261623440000093 ], [ 173.371104363, 0.253566799000069 ], [ 173.372894727000158, 0.242092190000108 ] ] ], [ [ [ 173.937103712000095, 0.310003973000093 ], [ 173.933604363000228, 0.308986721000124 ], [ 173.927582227000215, 0.312079169000114 ], [ 173.927093946000213, 0.315537828000032 ], [ 173.930511915000153, 0.318467515000052 ], [ 173.936045769000231, 0.320746161000116 ], [ 173.938975457000168, 0.327622789000117 ], [ 173.940521681000206, 0.340399481000162 ], [ 173.938649935999962, 0.344427802000126 ], [ 173.937754754000167, 0.349391994000172 ], [ 173.937998894000287, 0.357245184000163 ], [ 173.925466342000192, 0.399562893000081 ], [ 173.928314649000214, 0.405829169000114 ], [ 173.93246504000021, 0.401271877000084 ], [ 173.937510613000285, 0.388861395000148 ], [ 173.946950717000135, 0.360337632000054 ], [ 173.947032097000118, 0.322577216000084 ], [ 173.942800326000196, 0.315375067000147 ], [ 173.937103712000095, 0.310003973000093 ] ] ] ] } },
2 changes: 1 addition & 1 deletion version.hpp
Original file line number Diff line number Diff line change
@@ -1 +1 @@
#define VERSION "tippecanoe v1.19.1\n"
#define VERSION "tippecanoe v1.19.2\n"

0 comments on commit bd845ac

Please sign in to comment.