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

MS_MAP_PATTERN regex wont match files with hyphens #171

Open
DavidPavlicek opened this issue Jun 3, 2021 · 4 comments · Fixed by #172
Open

MS_MAP_PATTERN regex wont match files with hyphens #171

DavidPavlicek opened this issue Jun 3, 2021 · 4 comments · Fixed by #172

Comments

@DavidPavlicek
Copy link

When I try to pass mapfile with hyphens I got this validation error:

[warn] [pid 25] mod_fcgid: stderr: msCGILoadMap(): Web application error. CGI variable "map" fails to validate.
2098 - 172.17.0.1 - - [02/Jun/2021:04:57:42 +0000] "GET /?map=/etc/mapserver/puobod/krpk-puobod-red.map&request=getcapabilities&service=WMS HTTP/1.1" 200 620 "-" "Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 10.0; WOW64; Trident/7.0; .NET4.0C; .NET4.0E; .NET CLR 2.0.50727; .NET CLR 3.0.30729; .NET CLR 3.5.30729; InfoPath.3)"

It is caused by escaped hyphens in
MS_MAP_PATTERN=^\/etc\/mapserver\/([^\.][_A-Za-z0-9\-\.]+\/{1})*([_A-Za-z0-9\-\.]+\.map)$

It should probably look like this
MS_MAP_PATTERN=^\/etc\/mapserver\/([^\.][-_A-Za-z0-9\.]+\/{1})*([-_A-Za-z0-9\.]+\.map)$

Discussion about this error on MS mailing list:
http://osgeo-org.1560.x6.nabble.com/CGI-variable-quot-map-quot-fails-to-validate-td5487971.html

@sbrunner
Copy link
Member

sbrunner commented Jun 3, 2021

Thanks David, I will fix that :-)

@DavidPavlicek
Copy link
Author

Maybe this should simplify things even more...

-- quote from Steve Lime from discussion mentioned above --

I should note that 7.6.3 (also 7.4.5, 7.2.3 and 7.0.8) should make defining a value for MS_MAP_PATTERN much simpler. We updated things to use two filters instead of one. The first, MS_MAP_BAD_PATTERN, checks for problematic character sequences in the map value, for example /./, /../ or // and fails if there is a match. This means you don't have to account for those with MS_MAP_PATTERN alone and you can just write something simple like:

MS_MAP_PATTERN "^/etc/mapserver"

@sbrunner
Copy link
Member

sbrunner commented Jun 3, 2021

Thanks, I will have a look :-)

@sbrunner sbrunner reopened this Jun 4, 2021
@sbrunner
Copy link
Member

sbrunner commented Jun 4, 2021

Reopen to investigate about MS_MAP_BAD_PATTERN

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 a pull request may close this issue.

2 participants