--- parser3/src/main/pa_xml_io.C 2020/10/27 21:25:25 1.40 +++ parser3/src/main/pa_xml_io.C 2024/11/04 03:53:25 1.45 @@ -1,15 +1,15 @@ /** @file Parser: plugins to xml library, controlling i/o; implementation - Copyright (c) 2001-2017 Art. Lebedev Studio (http://www.artlebedev.com) - Author: Alexandr Petrosian (http://paf.design.ru) + Copyright (c) 2001-2024 Art. Lebedev Studio (http://www.artlebedev.com) + Authors: Konstantin Morshnev , Alexandr Petrosian */ #include "pa_xml_io.h" #ifdef XML -volatile const char * IDENT_PA_XML_IO_C="$Id: pa_xml_io.C,v 1.40 2020/10/27 21:25:25 moko Exp $" IDENT_PA_XML_IO_H; +volatile const char * IDENT_PA_XML_IO_C="$Id: pa_xml_io.C,v 1.45 2024/11/04 03:53:25 moko Exp $" IDENT_PA_XML_IO_H; #include "libxslt/extensions.h" @@ -17,15 +17,15 @@ volatile const char * IDENT_PA_XML_IO_C= #include "pa_globals.h" #include "pa_request.h" -THREAD_LOCAL HashStringBool* xml_dependencies = NULL; +THREAD_LOCAL HashStringBool* xml_dependencies = NULL; // every TLS should be referenced elsewhere, or GC will collect it static void add_dependency(const String::Body url) { if(xml_dependencies) // do we need to monitor now? xml_dependencies->put(url, true); } -void pa_xmlStartMonitoringDependencies() { - xml_dependencies=new HashStringBool; +HashStringBool* pa_xmlStartMonitoringDependencies() { + return xml_dependencies=new HashStringBool; // to keep another reference on TLS } void pa_xmlStopMonitoringDependencies() { @@ -82,17 +82,12 @@ static void *xmlFileOpenMonitor(const ch #endif Request& r=pa_thread_request(); - char adjust_buf[MAX_STRING]; if(!strncmp(afilename, "http://localhost", 16)) { const char* document_root=r.request_info.document_root; if(!document_root) document_root="."; - - adjust_buf[0]=0; - strcat(adjust_buf, document_root); - strcat(adjust_buf, &afilename[16]); - afilename=adjust_buf; - } else + afilename=pa_strcat(document_root, &afilename[16]); + } else { if(!strstr(afilename, "http://")) { if(strstr(afilename, "file://")) { afilename+=7 /*strlen("file://")*/; @@ -107,13 +102,14 @@ static void *xmlFileOpenMonitor(const ch return 0; // plug out [do not handle other prefixes] } } + afilename=pa_strdup(afilename); + } - const char* can_store_filename=pa_strdup(afilename); - add_dependency(can_store_filename); + add_dependency(afilename); const char *buf; try { - buf=file_load_text(r, *new String(can_store_filename), + buf=file_load_text(r, *new String(afilename), true /*fail_on_read_problem*/, 0 /*params*/, false /*don't transcode result because it must be fit with @encoding value!*/);