Closed
Bug 12500
Opened 26 years ago
Closed 26 years ago
HTTP Header Charset does not work for XUL/XML/RDF yet
Categories
(Core :: Internationalization, defect, P3)
Core
Internationalization
Tracking
()
VERIFIED
FIXED
M11
People
(Reporter: ftang, Assigned: ftang)
Details
(Whiteboard: code is there. Have not crate test cases yet.)
I fix the HTML part . But I have not fix the XML/XUL/RDF part
| Assignee | ||
Updated•26 years ago
|
Status: NEW → ASSIGNED
Target Milestone: M11
| Assignee | ||
Comment 1•26 years ago
|
||
Mark it assigned M11. Should be easy to do.
| Assignee | ||
Updated•26 years ago
|
Whiteboard: code is there. Have not crate test cases yet.
| Assignee | ||
Comment 2•26 years ago
|
||
Here is the fix. I have not test them yet.
Index: src/nsXMLDocument.cpp
===================================================================
RCS file: /m/pub/mozilla/layout/xml/document/src/nsXMLDocument.cpp,v
retrieving revision 1.37
diff -c -r1.37 nsXMLDocument.cpp
*** nsXMLDocument.cpp 1999/07/20 08:46:06 1.37
--- nsXMLDocument.cpp 1999/08/31 01:36:08
***************
*** 47,52 ****
--- 47,56 ----
#include "nsCOMPtr.h"
#include "nsIURI.h"
#endif
+ #include "nsXPIDLString.h"
+ #include "nsIHTTPChannel.h"
+ #include "nsIServiceManager.h"
+ #include "nsICharsetAlias.h"
// XXX The XML world depends on the html atoms
#include "nsHTMLAtoms.h"
***************
*** 226,236 ****
--- 230,280 ----
}
nsIWebShell* webShell;
+ nsAutoString charset("utf-8");
+ nsCharsetSource charsetSource = kCharsetFromDocTypeDefault;
#ifdef NECKO
nsCOMPtr<nsIURI> aUrl;
rv = aChannel->GetURI(getter_AddRefs(aUrl));
if (NS_FAILED(rv)) return rv;
+
+ nsCOMPtr<nsIHTTPChannel> httpChannel = do_QueryInterface(aChannel);
+ if(httpChannel) {
+ nsIAtom* contentTypeKey = NS_NewAtom("content-type");
+ nsXPIDLCString contenttypeheader;
+ rv = httpChannel->GetResponseHeader(contentTypeKey,
getter_Copies(contenttypeheader));
+ NS_RELEASE(contentTypeKey);
+ if (NS_SUCCEEDED(rv)) {
+ nsAutoString contentType;
+ contentType = contenttypeheader;
+ PRInt32 start = contentType.RFind("charset=", PR_TRUE ) ;
+ if(kNotFound != start)
+ {
+ start += 8; // 8 = "charset=".length
+ PRInt32 end = contentType.FindCharInSet(";\n\r ", start );
+ if(kNotFound == end )
+ end = contentType.Length();
+ nsAutoString theCharset;
+ contentType.Mid(theCharset, start, end - start);
+ nsICharsetAlias* calias = nsnull;
+ rv = nsServiceManager::GetService(
+ kCharsetAliasCID,
+
nsICharsetAlias::GetIID(),
+ (nsISupports**)
&calias);
+ if(NS_SUCCEEDED(rv) && (nsnull != calias) )
+ {
+ nsAutoString preferred;
+ rv = calias->GetPreferred(theCharset, preferred);
+ if(NS_SUCCEEDED(rv))
+ {
+ charset = preferred;
+ charsetSource = kCharsetFromHTTPHeader;
+ }
+ nsServiceManager::ReleaseService(kCharsetAliasCID,
calias);
+ }
+ }
+ }
+ }
#endif
static NS_DEFINE_IID(kCParserIID, NS_IPARSER_IID);
***************
*** 261,268 ****
/* Commenting out the call to RegisterDTD() as per rickg's
instructions.
XML and HTML DTD's are going to be pre-registered withing nsParser.
*/
// mParser->RegisterDTD(theDTD);
! nsAutoString utf8("utf-8");
! mParser->SetDocumentCharset(utf8, kCharsetFromDocTypeDefault);
mParser->SetCommand(aCommand);
mParser->SetContentSink(sink);
mParser->Parse(aUrl, nsnull, PR_FALSE, (void *)this);
--- 305,311 ----
/* Commenting out the call to RegisterDTD() as per rickg's
instructions.
XML and HTML DTD's are going to be pre-registered withing nsParser.
*/
// mParser->RegisterDTD(theDTD);
! mParser->SetDocumentCharset(charset, charsetSource);
mParser->SetCommand(aCommand);
mParser->SetContentSink(sink);
mParser->Parse(aUrl, nsnull, PR_FALSE, (void *)this);
Jim: Do you have a test case for this ?
| Assignee | ||
Comment 3•26 years ago
|
||
fix and check in nsTextFrame.cpp
| Assignee | ||
Updated•26 years ago
|
Status: ASSIGNED → RESOLVED
Closed: 26 years ago
Resolution: --- → FIXED
Updated•26 years ago
|
Status: RESOLVED → VERIFIED
Comment 4•26 years ago
|
||
Test cases are in http://babel/automation/erik/framework/
I verified this 9-30 build.
| Comment hidden (collapsed) |
You need to log in
before you can comment on or make changes to this bug.
Description
•