Merge pull request #429 from mapbox/bom2

Ignore UTF-8 byte order mark if present
This commit is contained in:
Eric Fischer
2017-06-29 15:25:31 -07:00
committed by GitHub
4 changed files with 23 additions and 4 deletions
+3
View File
@@ -1,3 +1,6 @@
## 1.19.2
* Ignore UTF-8 byte order mark if present
## 1.19.1 ## 1.19.1
* Add an option to increase maxzoom if features are still being dropped * Add an option to increase maxzoom if features are still being dropped
+18 -2
View File
@@ -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) { static inline int peek(json_pull *j) {
if (j->buffer_head < j->buffer_tail) { if (j->buffer_head < j->buffer_tail) {
return j->buffer[j->buffer_head]; return (unsigned char) j->buffer[j->buffer_head];
} else { } else {
j->buffer_head = 0; j->buffer_head = 0;
j->buffer_tail = j->read(j, j->buffer, BUFFER); j->buffer_tail = j->read(j, j->buffer, BUFFER);
if (j->buffer_head >= j->buffer_tail) { if (j->buffer_head >= j->buffer_tail) {
return EOF; return EOF;
} }
return j->buffer[j->buffer_head]; return (unsigned char) j->buffer[j->buffer_head];
} }
} }
@@ -295,6 +295,22 @@ again:
return NULL; 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); } while (c == ' ' || c == '\t' || c == '\r' || c == '\n' || c == 0x1E);
/////////////////////////// Arrays /////////////////////////// Arrays
File diff suppressed because one or more lines are too long
+1 -1
View File
@@ -1 +1 @@
#define VERSION "tippecanoe v1.19.1\n" #define VERSION "tippecanoe v1.19.2\n"