Feature #166 Network access cannot be disabled
This commit is contained in:
parent
27b5ba800c
commit
437e139f4c
|
@ -190,7 +190,7 @@ MyPropertySheet::MyPropertySheet (
|
||||||
}
|
}
|
||||||
|
|
||||||
libxmlNetAccessBox = new wxCheckBox (
|
libxmlNetAccessBox = new wxCheckBox (
|
||||||
generalPanel, wxID_ANY, _ ( "&Enable network access for DTD validation" ) );
|
generalPanel, wxID_ANY, _ ( "&Enable network access for XML validation" ) );
|
||||||
libxmlNetAccessBox->SetValue ( libxmlNetAccessParameter );
|
libxmlNetAccessBox->SetValue ( libxmlNetAccessParameter );
|
||||||
expandInternalEntitiesBox = new wxCheckBox (
|
expandInternalEntitiesBox = new wxCheckBox (
|
||||||
generalPanel, wxID_ANY, _ ( "E&xpand internal entities on open" ) );
|
generalPanel, wxID_ANY, _ ( "E&xpand internal entities on open" ) );
|
||||||
|
|
|
@ -33,7 +33,9 @@
|
||||||
|
|
||||||
using namespace xercesc;
|
using namespace xercesc;
|
||||||
|
|
||||||
void WrapXerces::Init() throw()
|
XMLNetAccessor *WrapXerces::mOriginalNetAccessor = NULL;
|
||||||
|
|
||||||
|
void WrapXerces::Init ( bool enableNetAccess ) throw()
|
||||||
{
|
{
|
||||||
static class Initializer
|
static class Initializer
|
||||||
{
|
{
|
||||||
|
@ -41,18 +43,19 @@ void WrapXerces::Init() throw()
|
||||||
Initializer ()
|
Initializer ()
|
||||||
{
|
{
|
||||||
XMLPlatformUtils::Initialize();
|
XMLPlatformUtils::Initialize();
|
||||||
|
mOriginalNetAccessor = XMLPlatformUtils::fgNetAccessor;
|
||||||
}
|
}
|
||||||
~Initializer()
|
~Initializer()
|
||||||
{
|
{
|
||||||
XMLPlatformUtils::Terminate();
|
XMLPlatformUtils::Terminate();
|
||||||
}
|
}
|
||||||
} dummy;
|
} dummy;
|
||||||
|
|
||||||
|
enableNetwork ( enableNetAccess );
|
||||||
}
|
}
|
||||||
|
|
||||||
WrapXerces::WrapXerces()
|
WrapXerces::WrapXerces()
|
||||||
{
|
{
|
||||||
WrapXerces::Init();
|
|
||||||
|
|
||||||
catalogResolver = new XercesCatalogResolver();
|
catalogResolver = new XercesCatalogResolver();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -206,6 +209,21 @@ wxMemoryBuffer WrapXerces::toString ( const wxString &str )
|
||||||
return buffer;
|
return buffer;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool WrapXerces::enableNetwork ( bool enable /*= true*/ )
|
||||||
|
{
|
||||||
|
bool ret = XMLPlatformUtils::fgNetAccessor != NULL;
|
||||||
|
if ( enable )
|
||||||
|
{
|
||||||
|
wxASSERT ( mOriginalNetAccessor != NULL );
|
||||||
|
XMLPlatformUtils::fgNetAccessor = mOriginalNetAccessor;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
XMLPlatformUtils::fgNetAccessor = NULL;
|
||||||
|
}
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
void MySAX2Handler::logError ( const wxString &type, wxLogLevel level,
|
void MySAX2Handler::logError ( const wxString &type, wxLogLevel level,
|
||||||
const SAXParseException& e )
|
const SAXParseException& e )
|
||||||
{
|
{
|
||||||
|
|
|
@ -94,7 +94,8 @@ class MySAX2Handler : public DefaultHandler
|
||||||
class WrapXerces : private boost::noncopyable
|
class WrapXerces : private boost::noncopyable
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
static void Init() throw ();
|
static void Init ( bool enableNetAccess ) throw ();
|
||||||
|
|
||||||
WrapXerces();
|
WrapXerces();
|
||||||
virtual ~WrapXerces();
|
virtual ~WrapXerces();
|
||||||
bool validate ( const wxString &fileName );
|
bool validate ( const wxString &fileName );
|
||||||
|
@ -118,9 +119,12 @@ class WrapXerces : private boost::noncopyable
|
||||||
//#else
|
//#else
|
||||||
static wxMemoryBuffer toString ( const wxString &str );
|
static wxMemoryBuffer toString ( const wxString &str );
|
||||||
//#endif
|
//#endif
|
||||||
|
// Returns original value
|
||||||
|
static bool enableNetwork ( bool enable = true );
|
||||||
|
|
||||||
private:
|
private:
|
||||||
static const wxMBConv &getMBConv();
|
static const wxMBConv &getMBConv();
|
||||||
|
static XMLNetAccessor *mOriginalNetAccessor;
|
||||||
|
|
||||||
XercesCatalogResolver *catalogResolver;
|
XercesCatalogResolver *catalogResolver;
|
||||||
MySAX2Handler mySAX2Handler;
|
MySAX2Handler mySAX2Handler;
|
||||||
|
|
|
@ -375,9 +375,6 @@ bool MyApp::OnInit()
|
||||||
wxImage::AddHandler ( new wxPNGHandler );
|
wxImage::AddHandler ( new wxPNGHandler );
|
||||||
wxSystemOptions::SetOption ( _T ( "msw.remap" ), 0 );
|
wxSystemOptions::SetOption ( _T ( "msw.remap" ), 0 );
|
||||||
|
|
||||||
// Initialize Xerces-C++
|
|
||||||
WrapXerces::Init();
|
|
||||||
|
|
||||||
frame = new MyFrame (
|
frame = new MyFrame (
|
||||||
_ ( "XML Copy Editor" ),
|
_ ( "XML Copy Editor" ),
|
||||||
config.get(),
|
config.get(),
|
||||||
|
@ -841,23 +838,6 @@ MyFrame::MyFrame (
|
||||||
xercescSSE2Warning = true;
|
xercescSSE2Warning = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( XMLPlatformUtils::fgSSE2ok
|
|
||||||
&& xercescSSE2Warning
|
|
||||||
&& wxTheApp->argc == 1 )
|
|
||||||
{
|
|
||||||
xercescSSE2Warning = wxMessageBox (
|
|
||||||
_ ("SSE2 is enabled in Xerces-C++ library. Xerces-C++ didn't "\
|
|
||||||
"use them in a thread-safe way. It may cause program crashes "\
|
|
||||||
"(segmentation faults).\n\n"\
|
|
||||||
"If it happens, please try compiling Xerces-C++ with SSE2 "\
|
|
||||||
"disabled.\n\n"\
|
|
||||||
"OK:\tShow this warning next time\n"\
|
|
||||||
"Cancel:\tDisable the warning\n"),
|
|
||||||
_ ("SSE2 problem in Xerces-C++"),
|
|
||||||
wxOK | wxCANCEL | wxICON_WARNING
|
|
||||||
) == wxOK;
|
|
||||||
}
|
|
||||||
|
|
||||||
largeFileProperties.completion = false;
|
largeFileProperties.completion = false;
|
||||||
largeFileProperties.fold = false;
|
largeFileProperties.fold = false;
|
||||||
largeFileProperties.whitespaceVisible = false;
|
largeFileProperties.whitespaceVisible = false;
|
||||||
|
@ -881,6 +861,26 @@ MyFrame::MyFrame (
|
||||||
// Initialize libxml
|
// Initialize libxml
|
||||||
WrapLibxml::Init ( catalogPath );
|
WrapLibxml::Init ( catalogPath );
|
||||||
|
|
||||||
|
// Initialize Xerces-C++
|
||||||
|
WrapXerces::Init ( libxmlNetAccess );
|
||||||
|
|
||||||
|
if ( XMLPlatformUtils::fgSSE2ok
|
||||||
|
&& xercescSSE2Warning
|
||||||
|
&& wxTheApp->argc == 1 )
|
||||||
|
{
|
||||||
|
xercescSSE2Warning = wxMessageBox (
|
||||||
|
_ ("SSE2 is enabled in Xerces-C++ library. Xerces-C++ didn't "\
|
||||||
|
"use them in a thread-safe way. It may cause program crashes "\
|
||||||
|
"(segmentation faults).\n\n"\
|
||||||
|
"If it happens, please try compiling Xerces-C++ with SSE2 "\
|
||||||
|
"disabled.\n\n"\
|
||||||
|
"OK:\tShow this warning next time\n"\
|
||||||
|
"Cancel:\tDisable the warning\n"),
|
||||||
|
_ ("SSE2 problem in Xerces-C++"),
|
||||||
|
wxOK | wxCANCEL | wxICON_WARNING
|
||||||
|
) == wxOK;
|
||||||
|
}
|
||||||
|
|
||||||
size_t findFlags = 0;
|
size_t findFlags = 0;
|
||||||
findFlags |= wxFR_DOWN;
|
findFlags |= wxFR_DOWN;
|
||||||
|
|
||||||
|
@ -2597,6 +2597,7 @@ void MyFrame::OnOptions ( wxCommandEvent& WXUNUSED ( event ) )
|
||||||
title ) );
|
title ) );
|
||||||
if ( mpsd->ShowModal() == wxID_OK )
|
if ( mpsd->ShowModal() == wxID_OK )
|
||||||
{
|
{
|
||||||
|
WrapXerces::enableNetwork ( libxmlNetAccess );
|
||||||
applyEditorProperties();
|
applyEditorProperties();
|
||||||
updatePaths();
|
updatePaths();
|
||||||
}
|
}
|
||||||
|
|
|
@ -34,7 +34,6 @@ XmlSchemaGenerator::XmlSchemaGenerator ( bool inlineSimpleType /*= true*/)
|
||||||
: mInlineSimpleType ( inlineSimpleType )
|
: mInlineSimpleType ( inlineSimpleType )
|
||||||
, mGrammarType ( Grammar::SchemaGrammarType )
|
, mGrammarType ( Grammar::SchemaGrammarType )
|
||||||
{
|
{
|
||||||
WrapXerces::Init();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
XmlSchemaGenerator::~XmlSchemaGenerator()
|
XmlSchemaGenerator::~XmlSchemaGenerator()
|
||||||
|
|
Loading…
Reference in New Issue