--- parser3/src/main/pa_common.C 2009/10/06 12:12:51 1.255 +++ parser3/src/main/pa_common.C 2010/05/17 22:54:49 1.258 @@ -26,7 +26,7 @@ * */ -static const char * const IDENT_COMMON_C="$Date: 2009/10/06 12:12:51 $"; +static const char * const IDENT_COMMON_C="$Date: 2010/05/17 22:54:49 $"; #include "pa_common.h" #include "pa_exception.h" @@ -264,8 +264,9 @@ File_read_result file_load(Request& r, c return result; } -#ifdef PA_SAFE_MODE + void check_safe_mode(struct stat finfo, const String& file_spec, const char* fname) { +#ifdef PA_SAFE_MODE if(finfo.st_uid/*foreign?*/!=geteuid() && finfo.st_gid/*foreign?*/!=getegid()) throw Exception(PARSER_RUNTIME, @@ -278,8 +279,9 @@ void check_safe_mode(struct stat finfo, fname, finfo.st_uid, geteuid(), finfo.st_gid, getegid()); +#endif } -#endif + bool file_read_action_under_lock(const String& file_spec, const char* action_name, File_read_action action, void *context, @@ -312,9 +314,7 @@ bool file_read_action_under_lock(const S "stat failed: %s (%d), actual filename '%s'", strerror(errno), errno, fname); -#ifdef PA_SAFE_MODE check_safe_mode(finfo, file_spec, fname); -#endif action(finfo, f, file_spec, fname, as_text, context); } catch(...) { @@ -328,7 +328,8 @@ bool file_read_action_under_lock(const S return true; } else { if(fail_on_read_problem) - throw Exception(errno==EACCES?"file.access":errno==ENOENT?"file.missing":0, + throw Exception(errno==EACCES?"file.access" + :(errno==ENOENT || errno==ENOTDIR || errno==ENODEV)?"file.missing":0, &file_spec, "%s failed: %s (%d), actual filename '%s'", action_name, strerror(errno), errno, fname); @@ -725,7 +726,7 @@ enum EscapeState { }; // @todo prescan for reduce required size (unescaped sting in 1 byte charset requires less memory usually) -char* unescape_chars(const char* cp, int len, Charset* charset, bool ignore_plus){ +char* unescape_chars(const char* cp, int len, Charset* charset, bool js){ char* s=new(PointerFreeGC) char[len+1]; // must be enough (%uXXXX==6 bytes, max utf-8 char length==6 bytes) char* dst=s; EscapeState escapeState=EscapeRest; @@ -734,12 +735,12 @@ char* unescape_chars(const char* cp, int short int jsCnt=0; while(srcPos