Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mapfile that is encoded as UTF-8 with BOM is not accepted #5194

Closed
wants to merge 1 commit into from
Closed

Mapfile that is encoded as UTF-8 with BOM is not accepted #5194

wants to merge 1 commit into from

Conversation

tbonfort
Copy link
Member

@tbonfort tbonfort commented Nov 7, 2015

Mapserver 7.0 does not accept mapfiles if they start with BOM. It seems that BOM has no effect in UTF-8 encoding http://www.unicode.org/faq/utf_bom.html#bom5 but some software still write it by default to text files, for example Notepad++
If mapfile starts with BOM Mapserver gives this error:
msLoadMap(): Unknown identifier. First token must be MAP, this doesn't look like a mapfile.
Issue can be tested with the attached mapfile that github did not accept it as "bom.map" so I renamed it into "bom.map.txt". It is easy to create by hand as well because the whole mapfile is just
MAP
END

Test query:
http://localhost/cgi-bin/mapserv.exe?map=bom.map

I think that making Mapserver to accept starting BOM could not break anything. Minimum action would be to mention the denial of BOM in the migration guide and in the mapfile documentation,

bom.map.txt

@tbonfort
Copy link
Member

tbonfort commented Nov 7, 2015

@jratike80 can try out the provided patch?
@sdlime can you review?

@tbonfort tbonfort changed the title Mapfile that is encoded as UFT-8 with BOM is not accepted Mapfile that is encoded as UTF-8 with BOM is not accepted Nov 7, 2015
@jratike80
Copy link
Author

jratike80 commented Nov 7, 2015

Sorry, I can test only with precompiled binaries like the Windows development builds in gisinternals.com. The issue is well defined and I trust that you understand what you did.

@sdlime
Copy link
Member

sdlime commented Nov 9, 2015

@tbonfort, patch looks reasonable to me. I wonder if it's really necessary but since it's easy... Any reason we'd support other BOMs?

@jratike80
Copy link
Author

jratike80 commented Nov 9, 2015

@sdlime, would you rather explain to Windows users why they can't create a proper mapfile with Notepad or why "UTF-8" selected from the menu of Notepad++ is not the correct one but they must select "UTF-8 without BOM" and so on? I think that this fix is friendly for the users and developers as well.

@tbonfort
Copy link
Member

tbonfort commented Nov 9, 2015

@sdlime no use in supporting other boms as we require mapfiles to be utf8 encoded

tbonfort added a commit that referenced this pull request Feb 24, 2016
@tbonfort
Copy link
Member

tbonfort commented Feb 24, 2016

rebased to branch-7-0 in e50c067

@tbonfort tbonfort closed this Feb 24, 2016
@tbonfort tbonfort added this to the 7.0.1 milestone Feb 24, 2016
@tbonfort tbonfort deleted the issues/5194-ignore-utf8-bom branch Feb 24, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants