1 #include "util_apache.h"
2 #include "util_const.h"
4 #include "util_splitter.h"
5 #include "util_string.h"
10 ustring apacheAbsolutePath (const ustring& url) {
12 std::vector<ustring> ary;
13 std::vector<ustring>::iterator it;
14 Splitter sp (url.begin (), url.end (), re_slash);
17 size_t len = url.length ();
19 if (len == 0 || url[len - 1] == '/') {
24 if (isAbsolutePath (url)) {
27 /* ustring e = getenvString (kSCRIPT_NAME);
28 ustring p = getenvString (kPATH_INFO);
29 if (p.length () > 0) e.append (p);
31 // mod_rewriteで書き換えた時、元のURLを返す
32 ustring e = getenvString (kREQUEST_URI);
33 // REQUEST_URIはデコードされていない。
34 ustring::size_type p = e.find_last_of ('?');
35 if (p != ustring::npos)
37 e = percentDecode (e); // ディレクトリパスをチェック前にデコードする。
38 splitE (e.begin (), e.end (), re_slash, ary);
39 if (ary.size () > 0 && ary.back ().length () > 0) {
47 } else if (match (b, e, CharConst ("."))) {
48 } else if (match (b, e, CharConst (".."))) {
52 ary.push_back (ustring (b, e));
56 for (it = ary.begin (); it != ary.end (); it ++) {
57 if ((*it).length () > 0) {
58 ans.append (uSlash).append (*it);