What's means this '(?U)' on nginx regex
fastcgi, nginx
Solution
?U is ungreedy match in regex. By default regex uses 'greedy' mode.
In this case, it's needed. With greedy match, this following request
/show.php/article/0001/another.php/something
will have the script part set as
/show.php/article/0001/another.php
This could cause unexpected security issue.
[UPDATE]
nginx uses pcre regex: http://www.pcre.org/pcre.txt
(?U) default ungreedy (lazy)
Problem
I was reading nginx's documentation, but a I don't what this '(?U)' are doing in this regex. http://wiki.nginx.org/HttpFastcgiModule#fastcgi_split_path_info Here's an example. The script show.php receives as argument the string article/0001. The following configuration will handle path splitting properly: ``` location ~ ^.+\.php { (...) fastcgi_split_path_info ^((?U).+\.php)(/?.+)$; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; fastcgi_param PATH_INFO $fastcgi_path_info; fastcgi_param PATH_TRANSLATED $document_root$fastcgi_path_info; (...) } ``` Requesting /show.php/article/0001 sets SCRIPT_FILENAME to /path/to/php/show.php and PATH_INFO to /article/0001. This regex is not enough? ``` fastcgi_split_path_info ^((?U).+\.php)(/?.+)$; ``` Thanks