diff options
| author | 2022-04-06 01:04:50 +0200 | |
|---|---|---|
| committer | 2022-04-06 01:04:50 +0200 | |
| commit | d25e919f29078127b0305f88cdcbc33a798c5d90 (patch) | |
| tree | 5cd4b3d75e2960f1c1d6c99fbeb55cba3cae44af | |
| parent | 106c4ee7f53ef800a82fce9638f29756e8b78640 (diff) | |
| download | libplist-d25e919f29078127b0305f88cdcbc33a798c5d90.tar.gz libplist-d25e919f29078127b0305f88cdcbc33a798c5d90.tar.bz2 | |
Skip whitespace to properly detect format in plist_from_memory()
| -rw-r--r-- | src/plist.c | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/src/plist.c b/src/plist.c index 9f3c8f4..78e71da 100644 --- a/src/plist.c +++ b/src/plist.c | |||
| @@ -199,10 +199,15 @@ PLIST_API plist_err_t plist_from_memory(const char *plist_data, uint32_t length, | |||
| 199 | } | 199 | } |
| 200 | if (plist_is_binary(plist_data, length)) { | 200 | if (plist_is_binary(plist_data, length)) { |
| 201 | res = plist_from_bin(plist_data, length, plist); | 201 | res = plist_from_bin(plist_data, length, plist); |
| 202 | } else if (plist_data[0] == '[' || plist_data[0] == '{') { | ||
| 203 | res = plist_from_json(plist_data, length, plist); | ||
| 204 | } else { | 202 | } else { |
| 205 | res = plist_from_xml(plist_data, length, plist); | 203 | /* skip whitespace before checking */ |
| 204 | uint32_t pos = 0; | ||
| 205 | while (pos < length && ((plist_data[pos] == ' ') || (plist_data[pos] == '\t') || (plist_data[pos] == '\r') || (plist_data[pos] == '\n'))) pos++; | ||
| 206 | if (plist_data[pos] == '[' || plist_data[pos] == '{') { | ||
| 207 | res = plist_from_json(plist_data, length, plist); | ||
| 208 | } else { | ||
| 209 | res = plist_from_xml(plist_data, length, plist); | ||
| 210 | } | ||
| 206 | } | 211 | } |
| 207 | return res; | 212 | return res; |
| 208 | } | 213 | } |
