Skip to content

Commit

Permalink
Ignore eventual leading UTF8 BOM (#5194)
Browse files Browse the repository at this point in the history
  • Loading branch information
tbonfort committed Feb 24, 2016
1 parent 9b93019 commit e50c067
Show file tree
Hide file tree
Showing 4 changed files with 2,021 additions and 2,000 deletions.
7 changes: 7 additions & 0 deletions mapfile.c
Original file line number Diff line number Diff line change
Expand Up @@ -6235,12 +6235,19 @@ int msSaveMap(mapObj *map, char *filename)
static int loadMapInternal(mapObj *map)
{
int foundMapToken=MS_FALSE;
int foundBomToken = MS_FALSE;
int token;

for(;;) {

token = msyylex();

if(!foundBomToken && token == BOM) {
foundBomToken = MS_TRUE;
if(!foundMapToken) {
continue; /*skip a leading bom*/
}
}
if(!foundMapToken && token != MAP) {
msSetError(MS_IDENTERR, "First token must be MAP, this doesn't look like a mapfile.", "msLoadMap()");
return(MS_FAILURE);
Expand Down
6 changes: 5 additions & 1 deletion mapfile.h
Original file line number Diff line number Diff line change
Expand Up @@ -312,6 +312,8 @@ enum MS_TOKEN_SOURCES {MS_FILE_TOKENS=0, MS_STRING_TOKENS, MS_URL_TOKENS};
#define SCALETOKEN 1270
#define VALUES 1271

#define TILESRS 1272

/* rfc 93 support for utfgrid */
#define UTFDATA 1280
#define UTFITEM 1281
Expand All @@ -321,9 +323,11 @@ enum MS_TOKEN_SOURCES {MS_FILE_TOKENS=0, MS_STRING_TOKENS, MS_URL_TOKENS};
#define COMPOP 1291
#define COMPFILTER 1292


#define BOM 1300

/* rfc59 bindvals objects */
#define BINDVALS 2000

#define TILESRS 1272

#endif /* MAPFILE_H */
Loading

0 comments on commit e50c067

Please sign in to comment.