Skip to content

Commit

Permalink
some changes
Browse files Browse the repository at this point in the history
  • Loading branch information
ctapmex committed Sep 18, 2024
1 parent 2378f44 commit af25c46
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 11 deletions.
4 changes: 2 additions & 2 deletions src/colorer/xml/XMLNode.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@
#include <unordered_map>
#include "colorer/Common.h"

inline const UnicodeString empty_string("");

class XMLNode
{
public:
Expand All @@ -16,6 +14,8 @@ class XMLNode

const UnicodeString& getAttrValue(const UnicodeString& key) const
{
static const UnicodeString empty_string("");

const auto found = attributes.find(key);
if (found == attributes.end()) {
return empty_string;
Expand Down
3 changes: 2 additions & 1 deletion src/colorer/xml/XmlInputSource.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,8 @@ XercesXmlInputSource* XmlInputSource::getInputSource() const

bool XmlInputSource::isFileURI(const UnicodeString& path, const UnicodeString* base)
{
if (path.startsWith(u"jar") || (base && base->startsWith(u"jar"))) {
const UnicodeString jar(u"jar:");
if (path.startsWith(jar) || (base && base->startsWith(jar))) {
return false;
}
return true;
Expand Down
14 changes: 7 additions & 7 deletions src/colorer/xml/libxml2/LibXmlReader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -136,14 +136,14 @@ xmlParserInputPtr LibXmlReader::xmlZipEntityLoader(const char* URL, const xmlPar
xmlParserInputPtr LibXmlReader::xmlMyExternalEntityLoader(const char* URL, const char* /*ID*/,
const xmlParserCtxtPtr ctxt)
{
// Функция вызывается перед каждым открытием файла в рамках libxml
// будь то xmlReadFile, или открытие файла для external entity

xmlParserInputPtr ret = nullptr;
// тут обработка имени файла для внешнего entity
// при этом если в entity указан нормальный путь файловой системы, без всяких переменных окружения, архивов,
// но можно с комбинацией ./ ../
// то в url будет указан полный путь, относительно текущего файла. libxml сама склеит путь.
// Иначе в url будет указан путь из самого entity, и дальше с ним над самому разбираться.
//
// в ctxt нет информации об обрабатываемом файле.

// libxml для external entity сам склеивает относительный путь от обрабатываемого файла, считая это путем файловой системы
// но для этого требуется заполнять filename у xmlParserInputPtr

#ifdef COLORER_FEATURE_ZIPINPUTSOURCE
if (current_jar) {
ret = xmlZipEntityLoader(URL, ctxt);
Expand Down
1 change: 0 additions & 1 deletion src/colorer/xml/libxml2/SharedXmlInputSource.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
#include "colorer/xml/libxml2/SharedXmlInputSource.h"
#include <fstream>
#include "colorer/Common.h"
#ifdef COLORER_FEATURE_OLD_COMPILERS
#include "colorer/platform/filesystem.hpp"
namespace fs = ghc::filesystem;
Expand Down

0 comments on commit af25c46

Please sign in to comment.