--- parser3/src/main/pa_xml_io.C 2009/01/25 02:05:08 1.23 +++ parser3/src/main/pa_xml_io.C 2016/10/26 15:44:50 1.32 @@ -1,7 +1,7 @@ /** @file Parser: plugins to xml library, controlling i/o; implementation - Copyright (c) 2001-2005 ArtLebedev Group (http://www.artlebedev.com) + Copyright (c) 2001-2015 Art. Lebedev Studio (http://www.artlebedev.com) Author: Alexandr Petrosian (http://paf.design.ru) */ @@ -9,7 +9,7 @@ #ifdef XML -static const char * const IDENT="$Date: 2009/01/25 02:05:08 $"; +volatile const char * IDENT_PA_XML_IO_C="$Id: pa_xml_io.C,v 1.32 2016/10/26 15:44:50 moko Exp $" IDENT_PA_XML_IO_H; #include "libxslt/extensions.h" @@ -17,50 +17,25 @@ static const char * const IDENT="$Date: #include "pa_globals.h" #include "pa_request.h" -static Hash xml_dependencies; +THREAD_LOCAL HashStringBool* xml_dependencies = NULL; static void add_dependency(const String::Body url) { - pa_thread_t thread_id=pa_get_thread_id(); - HashStringBool* urls; - { - SYNCHRONIZED; - - // try to get existing for this thread_id - urls=xml_dependencies.get(thread_id); - } - - if(urls) // do we need to monitor now? - urls->put(url, true); + if(xml_dependencies) // do we need to monitor now? + xml_dependencies->put(url, true); } void pa_xmlStartMonitoringDependencies() { - pa_thread_t thread_id=pa_get_thread_id(); - HashStringBool* urls=new HashStringBool; - { - SYNCHRONIZED; // find+fill blocked - - xml_dependencies.put(thread_id, urls); - } + xml_dependencies=new HashStringBool; } void pa_xmlStopMonitoringDependencies() { - pa_thread_t thread_id=pa_get_thread_id(); - { - SYNCHRONIZED; // find+fill blocked - - xml_dependencies.put(thread_id, 0); - } + xml_dependencies=NULL; } HashStringBool* pa_xmlGetDependencies() { - pa_thread_t thread_id=pa_get_thread_id(); - { - SYNCHRONIZED; // find+remove blocked - - HashStringBool* result=xml_dependencies.get(thread_id); - xml_dependencies.remove(thread_id); - return result; - } + HashStringBool* result=xml_dependencies; + xml_dependencies=NULL; + return result; } #ifndef DOXYGEN @@ -105,13 +80,25 @@ xmlFileOpen_ReadIntoStream (const char* strcat(adjust_buf, &do_not_store_filename[16]); do_not_store_filename=adjust_buf; } else - if(!strstr(do_not_store_filename, "http://")) - if(strstr(do_not_store_filename, "file://")) - do_not_store_filename+=7/*strlen("file://")*/; - else if(*do_not_store_filename && do_not_store_filename[1]!=':' && strstr(do_not_store_filename, "://")) { + if(!strstr(do_not_store_filename, "http://")) { + if(strstr(do_not_store_filename, "file://")) { + do_not_store_filename+=7/*strlen("file://")*/; +#ifdef WIN32 + if( + do_not_store_filename[0]=='/' + && do_not_store_filename[1] + && do_not_store_filename[2]==':' + && do_not_store_filename[3]=='/' + ) { + // skip leading slash for absolute path file:///C:/path/to/file + do_not_store_filename++; + } +#endif + } else if(*do_not_store_filename && do_not_store_filename[1]!=':' && strstr(do_not_store_filename, "://")) { pa_xmlStopMonitoringDependencies(); return 0; // plug out [do not handle other prefixes] } + } const char* can_store_filename=pa_strdup(do_not_store_filename); add_dependency(can_store_filename); @@ -130,7 +117,7 @@ xmlFileOpen_ReadIntoStream (const char* } catch(...) { buf="xmlFileOpen_ReadIntoStream: unknown error"; } - MemoryStream* stream=new(UseGC) MemoryStream; + MemoryStream* stream=new MemoryStream; stream->m_buf=buf; stream->m_size=strlen(buf); return (void *)stream; @@ -196,24 +183,17 @@ xmlFileOpenMethod (const char* afilename param_body.append_know_length(s, strlen(s)); VString* vparam=new VString(*new String(param_body, String::L_TAINTED)); - { - Temp_lang temp_lang(r, String::L_XML); // default language: XML - Request::Execute_nonvirtual_method_result body= - r.execute_nonvirtual_method(r.main_class, *method, vparam, true); - if(body.string) { - buf=body.string->cstr(String::L_UNSPECIFIED); - } else - throw Exception(0, - new String(afilename), - "'%s' method not found in %s class", - method_cstr, MAIN_CLASS_NAME); - } + Request::Execute_nonvirtual_method_result body=r.execute_nonvirtual_method(r.main_class, *method, vparam, true); + if(body.string) { + buf=body.string->untaint_cstr(String::L_XML); + } else + throw Exception(0, new String(afilename), "'%s' method not found in %s class", method_cstr, MAIN_CLASS_NAME); } catch(const Exception& e) { buf=e.comment(); } catch(...) { buf="xmlFileOpenLocalhost: unknown error"; } - MemoryStream* stream=new(UseGC) MemoryStream; + MemoryStream* stream=new MemoryStream; stream->m_buf=buf; stream->m_size=strlen(buf); return (void *)stream;