зеркало из https://github.com/mozilla/gecko-dev.git
Bug 57360. Handle non-ASCII characters as IDs and for document URLs. r=rjc, sr=alecf
This commit is contained in:
Родитель
b9ef69acf9
Коммит
a5bb0c8ff7
|
@ -1016,7 +1016,7 @@ RDFContentSinkImpl::GetIdAboutAttribute(const nsIParserNode& aNode,
|
||||||
nsAutoString uri(aNode.GetValueAt(i));
|
nsAutoString uri(aNode.GetValueAt(i));
|
||||||
nsRDFParserUtils::StripAndConvert(uri);
|
nsRDFParserUtils::StripAndConvert(uri);
|
||||||
|
|
||||||
rdf_MakeAbsoluteURI(NS_ConvertASCIItoUCS2(NS_STATIC_CAST(const char*, docURI)), uri);
|
rdf_MakeAbsoluteURI(NS_ConvertUTF8toUCS2(NS_STATIC_CAST(const char*, docURI)), uri);
|
||||||
|
|
||||||
return gRDFService->GetUnicodeResource(uri.GetUnicode(), aResource);
|
return gRDFService->GetUnicodeResource(uri.GetUnicode(), aResource);
|
||||||
}
|
}
|
||||||
|
@ -1027,29 +1027,17 @@ RDFContentSinkImpl::GetIdAboutAttribute(const nsIParserNode& aNode,
|
||||||
nsAutoString name(aNode.GetValueAt(i));
|
nsAutoString name(aNode.GetValueAt(i));
|
||||||
nsRDFParserUtils::StripAndConvert(name);
|
nsRDFParserUtils::StripAndConvert(name);
|
||||||
|
|
||||||
// Enforce that this is a valid "XML Name" (see
|
// In the spirit of leniency, we do not bother trying to
|
||||||
// http://www.w3.org/TR/REC-xml#NT-Nmtoken), as per 6.21.
|
// enforce that this be a valid "XML Name" (see
|
||||||
//
|
// http://www.w3.org/TR/REC-xml#NT-Nmtoken), as per
|
||||||
// XXX I'm assuming that nsString::IsAlpha() is defined to
|
// 6.21. If we wanted to, this would be where to do it.
|
||||||
// mean http://www.w3.org/TR/REC-xml#NT-Letter, which it
|
|
||||||
// probably isn't.
|
|
||||||
PRUnichar first = name.First();
|
|
||||||
if (! nsCRT::IsAsciiAlpha(first) &&
|
|
||||||
first != PRUnichar(':') &&
|
|
||||||
first != PRUnichar('_')) {
|
|
||||||
PR_LOG(gLog, PR_LOG_ALWAYS,
|
|
||||||
("rdfxml: expected XML Name at line %d",
|
|
||||||
aNode.GetSourceLineNumber()));
|
|
||||||
|
|
||||||
return NS_ERROR_FAILURE;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Construct an in-line resource whose URI is the
|
// Construct an in-line resource whose URI is the
|
||||||
// document's URI plus the XML name specified in the ID
|
// document's URI plus the XML name specified in the ID
|
||||||
// attribute.
|
// attribute.
|
||||||
name.Insert(NS_ConvertASCIItoUCS2("#"), 0);
|
name.Insert(PRUnichar('#'), 0);
|
||||||
|
|
||||||
rdf_MakeAbsoluteURI(NS_ConvertASCIItoUCS2(NS_STATIC_CAST(const char*, docURI)), name);
|
rdf_MakeAbsoluteURI(NS_ConvertUTF8toUCS2(NS_STATIC_CAST(const char*, docURI)), name);
|
||||||
|
|
||||||
return gRDFService->GetUnicodeResource(name.GetUnicode(), aResource);
|
return gRDFService->GetUnicodeResource(name.GetUnicode(), aResource);
|
||||||
}
|
}
|
||||||
|
@ -1105,7 +1093,7 @@ RDFContentSinkImpl::GetResourceAttribute(const nsIParserNode& aNode,
|
||||||
// appropriate...
|
// appropriate...
|
||||||
char* documentURL;
|
char* documentURL;
|
||||||
mDocumentURL->GetSpec(&documentURL);
|
mDocumentURL->GetSpec(&documentURL);
|
||||||
rdf_MakeAbsoluteURI(NS_ConvertASCIItoUCS2(documentURL), uri);
|
rdf_MakeAbsoluteURI(NS_ConvertUTF8toUCS2(documentURL), uri);
|
||||||
nsCRT::free(documentURL);
|
nsCRT::free(documentURL);
|
||||||
|
|
||||||
return gRDFService->GetUnicodeResource(uri.GetUnicode(), aResource);
|
return gRDFService->GetUnicodeResource(uri.GetUnicode(), aResource);
|
||||||
|
@ -1243,7 +1231,7 @@ RDFContentSinkImpl::ReinitContainer(nsIRDFResource* aContainerType, nsIRDFResour
|
||||||
nsresult rv;
|
nsresult rv;
|
||||||
|
|
||||||
nsCOMPtr<nsIRDFLiteral> one;
|
nsCOMPtr<nsIRDFLiteral> one;
|
||||||
rv = gRDFService->GetLiteral(NS_ConvertASCIItoUCS2("1").GetUnicode(), getter_AddRefs(one));
|
rv = gRDFService->GetLiteral(NS_LITERAL_STRING("1").get(), getter_AddRefs(one));
|
||||||
if (NS_FAILED(rv)) return rv;
|
if (NS_FAILED(rv)) return rv;
|
||||||
|
|
||||||
// Re-initialize the 'nextval' property
|
// Re-initialize the 'nextval' property
|
||||||
|
|
Загрузка…
Ссылка в новой задаче