Module: wine Branch: master Commit: 58a261b7d1293deefcb66242b0435ee869a6c748 URL: http://source.winehq.org/git/wine.git/?a=commit;h=58a261b7d1293deefcb66242b0...
Author: Jacek Caban jacek@codeweavers.com Date: Thu Apr 12 21:25:08 2007 +0200
mshtml: Correctly handle utf-16 encoded pages.
---
dlls/mshtml/mshtml_private.h | 1 + dlls/mshtml/navigate.c | 27 +++++++++++++++++---------- dlls/mshtml/nsio.c | 19 +++++++++++++++---- 3 files changed, 33 insertions(+), 14 deletions(-)
diff --git a/dlls/mshtml/mshtml_private.h b/dlls/mshtml/mshtml_private.h index 7038c70..6d8e154 100644 --- a/dlls/mshtml/mshtml_private.h +++ b/dlls/mshtml/mshtml_private.h @@ -165,6 +165,7 @@ typedef struct { nsLoadFlags load_flags; nsIURI *original_uri; char *content; + char *charset; } nsChannel;
typedef struct { diff --git a/dlls/mshtml/navigate.c b/dlls/mshtml/navigate.c index f9525e7..a30df13 100644 --- a/dlls/mshtml/navigate.c +++ b/dlls/mshtml/navigate.c @@ -37,6 +37,7 @@ WINE_DEFAULT_DEBUG_CHANNEL(mshtml);
#define CONTENT_LENGTH "Content-Length" +#define UTF16_STR "utf-16"
#define NSINSTREAM(x) ((nsIInputStream*) &(x)->lpInputStreamVtbl)
@@ -399,31 +400,37 @@ static HRESULT WINAPI BindStatusCallback_OnDataAvailable(IBindStatusCallback *if TRACE("(%p)->(%08x %d %p %p)\n", This, grfBSCF, dwSize, pformatetc, pstgmed);
if(This->nslistener) { - if(!This->nsstream) { + if(!This->nsstream) This->nsstream = create_nsprotocol_stream(pstgmed->u.pstm);
- nsres = nsIStreamListener_OnStartRequest(This->nslistener, - (nsIRequest*)NSCHANNEL(This->nschannel), This->nscontext); - if(NS_FAILED(nsres)) - FIXME("OnStartRequest failed: %08x\n", nsres); - } - do { hres = IStream_Read(pstgmed->u.pstm, This->nsstream->buf, sizeof(This->nsstream->buf), &This->nsstream->buf_size); if(!This->nsstream->buf_size) break;
+ if(!This->readed && This->nsstream->buf_size >= 2 && *(WORD*)This->nsstream->buf == 0xfeff) { + This->nschannel->charset = mshtml_alloc(sizeof(UTF16_STR)); + memcpy(This->nschannel->charset, UTF16_STR, sizeof(UTF16_STR)); + } + + if(!This->readed) { + nsres = nsIStreamListener_OnStartRequest(This->nslistener, + (nsIRequest*)NSCHANNEL(This->nschannel), This->nscontext); + if(NS_FAILED(nsres)) + FIXME("OnStartRequest failed: %08x\n", nsres); + } + + This->readed += This->nsstream->buf_size; + nsres = nsIStreamListener_OnDataAvailable(This->nslistener, (nsIRequest*)NSCHANNEL(This->nschannel), This->nscontext, NSINSTREAM(This->nsstream), This->readed, This->nsstream->buf_size); if(NS_FAILED(nsres)) - FIXME("OnDataAvailable failed: %08x\n", nsres); + ERR("OnDataAvailable failed: %08x\n", nsres);
if(This->nsstream->buf_size) FIXME("buffer is not empty!\n"); - - This->readed += This->nsstream->buf_size; }while(hres == S_OK); }else { BYTE buf[1024]; diff --git a/dlls/mshtml/nsio.c b/dlls/mshtml/nsio.c index 06bad64..e3eba43 100644 --- a/dlls/mshtml/nsio.c +++ b/dlls/mshtml/nsio.c @@ -221,6 +221,7 @@ static nsrefcnt NSAPI nsChannel_Release(nsIHttpChannel *iface) if(This->original_uri) nsIURI_Release(This->original_uri); mshtml_free(This->content); + mshtml_free(This->charset); mshtml_free(This); }
@@ -512,11 +513,20 @@ static nsresult NSAPI nsChannel_GetContentCharset(nsIHttpChannel *iface,
TRACE("(%p)->(%p)\n", This, aContentCharset);
- if(This->channel) - return nsIChannel_GetContentCharset(This->channel, aContentCharset); + if(This->charset) { + nsACString_SetData(aContentCharset, This->charset); + return NS_OK; + }
- FIXME("default action not implemented\n"); - return NS_ERROR_NOT_IMPLEMENTED; + if(This->channel) { + nsresult nsres = nsIChannel_GetContentCharset(This->channel, aContentCharset); + const char *ch; + nsACString_GetData(aContentCharset, &ch, NULL); + return nsres; + } + + nsACString_SetData(aContentCharset, ""); + return NS_OK; }
static nsresult NSAPI nsChannel_SetContentCharset(nsIHttpChannel *iface, @@ -1871,6 +1881,7 @@ static nsresult NSAPI nsIOService_NewChannelFromURI(nsIIOService *iface, nsIURI ret->notif_callback = NULL; ret->load_flags = 0; ret->content = NULL; + ret->charset = NULL;
nsIURI_AddRef(aURI); ret->original_uri = aURI;