- Timestamp:
- 2024-05-07T14:46:46+12:00 (6 weeks ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
main/trunk/greenstone2/runtime-src/src/recpt/receptionist.cpp
r31980 r39000 63 63 macrofiles.erase(macrofiles.begin(), macrofiles.end()); 64 64 saveconf.clear(); 65 usecookies = false; 65 usecookiesForUID = false; 66 usecookiesForE = true; 66 67 logcgiargs = false; 67 68 LogDateFormat = LocalTime; … … 251 252 } 252 253 else if (key == "saveconf") configinfo.saveconf = cfgline[0]; 253 else if (key == "usecookies") configinfo.usecookies = (cfgline[0] == "true"); 254 // keep usecookies here for backwards compatibility 255 else if (key == "usecookies" || key == "usecookiesForUID") configinfo.usecookiesForUID = (cfgline[0] == "true"); 256 else if (key == "usecookiesForE") configinfo.usecookiesForE = (cfgline[0] == "true"); 254 257 else if (key == "logcgiargs") configinfo.logcgiargs = (cfgline[0] == "true"); 255 258 else if (key == "maintainer") configinfo.maintainer = cfgline[0]; … … 594 597 args.clear(); 595 598 split_cgi_args (argsinfo, argstr, args); 596 599 600 // get e cookie 601 if (configinfo.usecookiesForE) get_named_cookie(args["e"], "GSDL_E", fcgienv); 597 602 // expand the compressed argument (if there was one) 598 603 if (!expand_save_args (argsinfo, configinfo.saveconf, args, logout)) return false; … … 605 610 606 611 // get the cookie 607 if (configinfo.usecookies ) get_cookie(args["z"], fcgienv);612 if (configinfo.usecookiesForUID) get_uid_cookie(args["z"], fcgienv); 608 613 609 614 // if we're changing languages, set the encoding to the default for the new language … … 672 677 673 678 679 // Returns true if cookie exists, false if not 680 bool receptionist::get_named_cookie (text_t &cookie, text_t cookie_name, text_tmap &fcgienv) 681 { 682 683 // See if we can get the cookies 684 text_t cookiestring = gsdl_getenv ("HTTP_COOKIE", fcgienv); 685 if (cookiestring.empty()) return false; 686 // This should really be handled by the findword function... 687 688 // Check if the cookie contains 'cookie_name' 689 text_t cid = cookie_name+"="; 690 text_t::iterator cid_start = findword(cookiestring.begin(), cookiestring.end(), cid); 691 if (cid_start != cookiestring.end()) 692 { 693 // Yes, so extract its value 694 cookie = substr(cid_start + cid.size(), findchar(cid_start + cid.size(), cookiestring.end(), ';')); 695 return true; 696 } 697 return false; 698 } 699 674 700 // Returns true if cookie already existed, false if it was generated 675 bool receptionist::get_ cookie (text_t &cookie, text_tmap &fcgienv)701 bool receptionist::get_uid_cookie (text_t &cookie, text_tmap &fcgienv) 676 702 { 677 703 // See if we can get the GSDL_UID cookie 678 text_t cookiestring = gsdl_getenv ("HTTP_COOKIE", fcgienv); 679 if (!cookiestring.empty()) // This should really be handled by the findword function... 680 { 681 // Check if the cookie contains GSDL_UID 682 text_t gsdl_uid = "GSDL_UID="; 683 text_t::iterator gsdl_uid_start = findword(cookiestring.begin(), cookiestring.end(), gsdl_uid); 684 if (gsdl_uid_start != cookiestring.end()) 685 { 686 // Yes, so extract its value 687 cookie = substr(gsdl_uid_start + gsdl_uid.size(), findchar(gsdl_uid_start + gsdl_uid.size(), cookiestring.end(), ';')); 688 return true; 689 } 690 } 691 704 bool found = get_named_cookie(cookie, "GSDL_UID", fcgienv); 705 if (found) return true; 692 706 // Generate a new key "[host]-[epoch time]", e.g. test.com-1256764496 693 707 cookie.clear(); … … 706 720 707 721 // Same as above but just tests if cookie exists 708 bool receptionist:: get_cookie (text_tmap &fcgienv)722 bool receptionist::has_uid_cookie (text_tmap &fcgienv) 709 723 { 710 724 text_t cookie_jar = ""; 711 return get_cookie(cookie_jar, fcgienv); 725 return get_named_cookie(cookie_jar, "GSDL_UID", fcgienv); 726 712 727 } 713 728 … … 957 972 958 973 // add cookie if required 959 if (configinfo.usecookies && !get_cookie(fcgienv))974 if (configinfo.usecookiesForUID && !has_uid_cookie(fcgienv)) 960 975 response_data += "\nSet-Cookie: GSDL_UID=" + args["z"] 961 976 + "; expires=Fri, 25-Dec-2037 00:00:00 GMT"; 977 if (configinfo.usecookiesForE) { 978 // set the GSDL_E cookie 979 response_data += "\nSet-Cookie: GSDL_E=" + get_compressed_arg (args, logout) 980 + "; expires=Fri, 25-Dec-2037 00:00:00 GMT"; 981 } 982 962 983 } 963 984 } … … 1476 1497 1477 1498 1478 text_t compressedoptions = get_compressed_arg(args, logout); 1499 text_t compressedoptions = ""; 1500 if (!configinfo.usecookiesForE) { 1501 compressedoptions = get_compressed_arg(args, logout); 1502 } 1479 1503 disp.setmacro ("compressedoptions", displayclass::defaultpackage, dm_safe(compressedoptions)); 1480 1504 //disp.setmacro ("compressedoptionsUrlsafe", displayclass::defaultpackage, encodeForURL(dm_safe(compressedoptions))); // seems to be unnecessary after testing e=hack or e=hack<collect>... or e=...<collect>hack in a live server … … 1498 1522 // the old version was dm_safed, so make a dm safe version in case we need it 1499 1523 disp.setmacro ("decodedcompressedoptionsAttrDmsafe", displayclass::defaultpackage, encodeForHTMLAttr(dm_safe(dmacrovalue))); 1524 1500 1525 1501 1526 #if defined (__WIN32__)
Note:
See TracChangeset
for help on using the changeset viewer.