bug 205675, error on recursive import/include, r=sicking, sr=peterv, a=asa
git-svn-id: svn://10.0.0.236/trunk@183747 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
@@ -84,4 +84,7 @@
|
||||
#define NS_ERROR_XSLT_WRONG_MIME_TYPE \
|
||||
NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_XSLT, 11)
|
||||
|
||||
#define NS_ERROR_XSLT_LOAD_RECURSION \
|
||||
NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_XSLT, 12)
|
||||
|
||||
#endif // __TX_ERROR
|
||||
|
||||
@@ -188,6 +188,10 @@ int main(int argc, char** argv)
|
||||
*resultOutput, obs);
|
||||
}
|
||||
|
||||
if (NS_FAILED(rv)) {
|
||||
cerr << "transformation failed with " << hex << rv;
|
||||
}
|
||||
|
||||
resultFileStream.close();
|
||||
txXSLTProcessor::shutdown();
|
||||
rv = NS_ShutdownXPCOM(nsnull);
|
||||
|
||||
@@ -67,6 +67,8 @@ class txDriver : public txACompileObserver
|
||||
protected:
|
||||
void createErrorString();
|
||||
nsString mErrorString;
|
||||
// keep track of the nsresult returned by the handlers, expat forgets them
|
||||
nsresult mRV;
|
||||
XML_Parser mExpatParser;
|
||||
nsAutoRefCnt mRefCnt;
|
||||
};
|
||||
@@ -185,11 +187,13 @@ txDriver::parse(istream& aInputStream, const nsAString& aUri)
|
||||
char buf[bufferSize];
|
||||
PRBool done;
|
||||
int success;
|
||||
mRV = NS_OK;
|
||||
do {
|
||||
aInputStream.read(buf, bufferSize);
|
||||
done = aInputStream.eof();
|
||||
success = XML_Parse(mExpatParser, buf, aInputStream.gcount(), done);
|
||||
if (!success) {
|
||||
// mRV is set in onDoneCompiling in case of an error
|
||||
if (!success || NS_FAILED(mRV)) {
|
||||
createErrorString();
|
||||
done = MB_TRUE;
|
||||
}
|
||||
@@ -202,7 +206,7 @@ txDriver::parse(istream& aInputStream, const nsAString& aUri)
|
||||
if (!success) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
return NS_OK;
|
||||
return mRV;
|
||||
}
|
||||
|
||||
const nsAString&
|
||||
@@ -227,7 +231,6 @@ txDriver::StartElement(const XML_Char *aName, const XML_Char **aAtts)
|
||||
attcount/2, idOffset);
|
||||
if (NS_FAILED(rv)) {
|
||||
mCompiler->cancel(rv);
|
||||
return XML_ERROR_SYNTAX;
|
||||
}
|
||||
return XML_ERROR_NONE;
|
||||
}
|
||||
@@ -339,6 +342,8 @@ void
|
||||
txDriver::onDoneCompiling(txStylesheetCompiler* aCompiler, nsresult aResult,
|
||||
const PRUnichar *aErrorText, const PRUnichar *aParam)
|
||||
{
|
||||
// store the nsresult as expat forgets about it
|
||||
mRV = aResult;
|
||||
}
|
||||
|
||||
nsresult
|
||||
|
||||
@@ -402,7 +402,8 @@ nsresult
|
||||
txStylesheetCompiler::doneLoading()
|
||||
{
|
||||
PR_LOG(txLog::xslt, PR_LOG_ALWAYS,
|
||||
("Compiler::doneLoading: %s\n", mURI.get()));
|
||||
("Compiler::doneLoading: %s\n",
|
||||
NS_LossyConvertUCS2toASCII(mURI).get()));
|
||||
if (NS_FAILED(mStatus)) {
|
||||
return mStatus;
|
||||
}
|
||||
@@ -418,7 +419,8 @@ txStylesheetCompiler::cancel(nsresult aError, const PRUnichar *aErrorText,
|
||||
{
|
||||
PR_LOG(txLog::xslt, PR_LOG_ALWAYS,
|
||||
("Compiler::cancel: %s, module: %d, code %d\n",
|
||||
mURI.get(), NS_ERROR_GET_MODULE(aError),
|
||||
NS_LossyConvertUCS2toASCII(mURI).get(),
|
||||
NS_ERROR_GET_MODULE(aError),
|
||||
NS_ERROR_GET_CODE(aError)));
|
||||
if (NS_SUCCEEDED(mStatus)) {
|
||||
mStatus = aError;
|
||||
@@ -444,7 +446,11 @@ txStylesheetCompiler::loadURI(const nsAString& aUri,
|
||||
{
|
||||
PR_LOG(txLog::xslt, PR_LOG_ALWAYS,
|
||||
("Compiler::loadURI forwards %s thru %s\n",
|
||||
NS_LossyConvertUCS2toASCII(aUri).get(), mURI.get()));
|
||||
NS_LossyConvertUCS2toASCII(aUri).get(),
|
||||
NS_LossyConvertUCS2toASCII(mURI).get()));
|
||||
if (mURI.Equals(aUri)) {
|
||||
return NS_ERROR_XSLT_LOAD_RECURSION;
|
||||
}
|
||||
return mObserver ? mObserver->loadURI(aUri, aCompiler) : NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
@@ -561,9 +567,7 @@ txStylesheetCompilerState::init(const nsAString& aBaseURI,
|
||||
{
|
||||
NS_ASSERTION(!aStylesheet || aInsertPosition,
|
||||
"must provide insertposition if loading subsheet");
|
||||
#ifdef PR_LOGGING
|
||||
mURI.AssignWithConversion(aBaseURI);
|
||||
#endif
|
||||
mURI = aBaseURI;
|
||||
// Check for fragment identifier of an embedded stylesheet.
|
||||
PRInt32 fragment = aBaseURI.FindChar('#') + 1;
|
||||
if (fragment > 0) {
|
||||
@@ -755,6 +759,9 @@ txStylesheetCompilerState::loadIncludedStylesheet(const nsAString& aURI)
|
||||
PR_LOG(txLog::xslt, PR_LOG_ALWAYS,
|
||||
("CompilerState::loadIncludedStylesheet: %s\n",
|
||||
NS_LossyConvertUCS2toASCII(aURI).get()));
|
||||
if (mURI.Equals(aURI)) {
|
||||
return NS_ERROR_XSLT_LOAD_RECURSION;
|
||||
}
|
||||
NS_ENSURE_TRUE(mObserver, NS_ERROR_NOT_IMPLEMENTED);
|
||||
|
||||
nsAutoPtr<txToplevelItem> item(new txDummyItem);
|
||||
@@ -798,6 +805,9 @@ txStylesheetCompilerState::loadImportedStylesheet(const nsAString& aURI,
|
||||
PR_LOG(txLog::xslt, PR_LOG_ALWAYS,
|
||||
("CompilerState::loadImportedStylesheet: %s\n",
|
||||
NS_LossyConvertUCS2toASCII(aURI).get()));
|
||||
if (mURI.Equals(aURI)) {
|
||||
return NS_ERROR_XSLT_LOAD_RECURSION;
|
||||
}
|
||||
NS_ENSURE_TRUE(mObserver, NS_ERROR_NOT_IMPLEMENTED);
|
||||
|
||||
txListIterator iter(&aFrame->mToplevelItems);
|
||||
|
||||
@@ -171,9 +171,7 @@ protected:
|
||||
eInEmbed,
|
||||
eHasEmbed
|
||||
} mEmbedStatus;
|
||||
#ifdef PR_LOGGING
|
||||
nsCString mURI;
|
||||
#endif
|
||||
nsString mURI;
|
||||
PRPackedBool mIsTopCompiler;
|
||||
PRPackedBool mDoneWithThisStylesheet;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user