summaryrefslogtreecommitdiff
path: root/apps/gui/wps_parser.c
diff options
context:
space:
mode:
Diffstat (limited to 'apps/gui/wps_parser.c')
-rw-r--r--apps/gui/wps_parser.c18
1 files changed, 17 insertions, 1 deletions
diff --git a/apps/gui/wps_parser.c b/apps/gui/wps_parser.c
index b2969ecb34..3a85b5fad5 100644
--- a/apps/gui/wps_parser.c
+++ b/apps/gui/wps_parser.c
@@ -671,7 +671,7 @@ static bool wps_parse(struct wps_data *data, const char *wps_bufptr)
671 char *current_string = data->string_buffer; 671 char *current_string = data->string_buffer;
672 672
673 while(*wps_bufptr && data->num_tokens < WPS_MAX_TOKENS - 1 673 while(*wps_bufptr && data->num_tokens < WPS_MAX_TOKENS - 1
674 && data->num_lines < WPS_MAX_LINES) 674 && data->num_lines < WPS_MAX_LINES)
675 { 675 {
676 switch(*wps_bufptr++) 676 switch(*wps_bufptr++)
677 { 677 {
@@ -906,6 +906,19 @@ static void load_wps_bitmaps(struct wps_data *wps_data, char *bmpdir)
906 906
907#endif /* HAVE_LCD_BITMAP */ 907#endif /* HAVE_LCD_BITMAP */
908 908
909/* Skip leading UTF-8 BOM, if present. */
910static char *skip_utf8_bom(char *buf)
911{
912 unsigned char *s = (unsigned char *)buf;
913
914 if(s[0] == 0xef && s[1] == 0xbb && s[2] == 0xbf)
915 {
916 buf += 3;
917 }
918
919 return buf;
920}
921
909/* to setup up the wps-data from a format-buffer (isfile = false) 922/* to setup up the wps-data from a format-buffer (isfile = false)
910 from a (wps-)file (isfile = true)*/ 923 from a (wps-)file (isfile = true)*/
911bool wps_data_load(struct wps_data *wps_data, 924bool wps_data_load(struct wps_data *wps_data,
@@ -975,6 +988,9 @@ bool wps_data_load(struct wps_data *wps_data,
975 clear_bmp_names(); 988 clear_bmp_names();
976#endif 989#endif
977 990
991 /* Skip leading UTF-8 BOM, if present. */
992 wps_buffer = skip_utf8_bom(wps_buffer);
993
978 /* parse the WPS source */ 994 /* parse the WPS source */
979 if (!wps_parse(wps_data, wps_buffer)) 995 if (!wps_parse(wps_data, wps_buffer))
980 return false; 996 return false;