mshtml: Correctly handle utf-16 encoded pages.
This commit is contained in:
parent
f44e289a86
commit
58a261b7d1
|
@ -165,6 +165,7 @@ typedef struct {
|
||||||
nsLoadFlags load_flags;
|
nsLoadFlags load_flags;
|
||||||
nsIURI *original_uri;
|
nsIURI *original_uri;
|
||||||
char *content;
|
char *content;
|
||||||
|
char *charset;
|
||||||
} nsChannel;
|
} nsChannel;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
|
|
|
@ -37,6 +37,7 @@
|
||||||
WINE_DEFAULT_DEBUG_CHANNEL(mshtml);
|
WINE_DEFAULT_DEBUG_CHANNEL(mshtml);
|
||||||
|
|
||||||
#define CONTENT_LENGTH "Content-Length"
|
#define CONTENT_LENGTH "Content-Length"
|
||||||
|
#define UTF16_STR "utf-16"
|
||||||
|
|
||||||
#define NSINSTREAM(x) ((nsIInputStream*) &(x)->lpInputStreamVtbl)
|
#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);
|
TRACE("(%p)->(%08x %d %p %p)\n", This, grfBSCF, dwSize, pformatetc, pstgmed);
|
||||||
|
|
||||||
if(This->nslistener) {
|
if(This->nslistener) {
|
||||||
if(!This->nsstream) {
|
if(!This->nsstream)
|
||||||
This->nsstream = create_nsprotocol_stream(pstgmed->u.pstm);
|
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 {
|
do {
|
||||||
hres = IStream_Read(pstgmed->u.pstm, This->nsstream->buf, sizeof(This->nsstream->buf),
|
hres = IStream_Read(pstgmed->u.pstm, This->nsstream->buf, sizeof(This->nsstream->buf),
|
||||||
&This->nsstream->buf_size);
|
&This->nsstream->buf_size);
|
||||||
if(!This->nsstream->buf_size)
|
if(!This->nsstream->buf_size)
|
||||||
break;
|
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,
|
nsres = nsIStreamListener_OnDataAvailable(This->nslistener,
|
||||||
(nsIRequest*)NSCHANNEL(This->nschannel), This->nscontext,
|
(nsIRequest*)NSCHANNEL(This->nschannel), This->nscontext,
|
||||||
NSINSTREAM(This->nsstream), This->readed, This->nsstream->buf_size);
|
NSINSTREAM(This->nsstream), This->readed, This->nsstream->buf_size);
|
||||||
if(NS_FAILED(nsres))
|
if(NS_FAILED(nsres))
|
||||||
FIXME("OnDataAvailable failed: %08x\n", nsres);
|
ERR("OnDataAvailable failed: %08x\n", nsres);
|
||||||
|
|
||||||
if(This->nsstream->buf_size)
|
if(This->nsstream->buf_size)
|
||||||
FIXME("buffer is not empty!\n");
|
FIXME("buffer is not empty!\n");
|
||||||
|
|
||||||
This->readed += This->nsstream->buf_size;
|
|
||||||
}while(hres == S_OK);
|
}while(hres == S_OK);
|
||||||
}else {
|
}else {
|
||||||
BYTE buf[1024];
|
BYTE buf[1024];
|
||||||
|
|
|
@ -221,6 +221,7 @@ static nsrefcnt NSAPI nsChannel_Release(nsIHttpChannel *iface)
|
||||||
if(This->original_uri)
|
if(This->original_uri)
|
||||||
nsIURI_Release(This->original_uri);
|
nsIURI_Release(This->original_uri);
|
||||||
mshtml_free(This->content);
|
mshtml_free(This->content);
|
||||||
|
mshtml_free(This->charset);
|
||||||
mshtml_free(This);
|
mshtml_free(This);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -512,11 +513,20 @@ static nsresult NSAPI nsChannel_GetContentCharset(nsIHttpChannel *iface,
|
||||||
|
|
||||||
TRACE("(%p)->(%p)\n", This, aContentCharset);
|
TRACE("(%p)->(%p)\n", This, aContentCharset);
|
||||||
|
|
||||||
if(This->channel)
|
if(This->charset) {
|
||||||
return nsIChannel_GetContentCharset(This->channel, aContentCharset);
|
nsACString_SetData(aContentCharset, This->charset);
|
||||||
|
return NS_OK;
|
||||||
|
}
|
||||||
|
|
||||||
FIXME("default action not implemented\n");
|
if(This->channel) {
|
||||||
return NS_ERROR_NOT_IMPLEMENTED;
|
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,
|
static nsresult NSAPI nsChannel_SetContentCharset(nsIHttpChannel *iface,
|
||||||
|
@ -1871,6 +1881,7 @@ static nsresult NSAPI nsIOService_NewChannelFromURI(nsIIOService *iface, nsIURI
|
||||||
ret->notif_callback = NULL;
|
ret->notif_callback = NULL;
|
||||||
ret->load_flags = 0;
|
ret->load_flags = 0;
|
||||||
ret->content = NULL;
|
ret->content = NULL;
|
||||||
|
ret->charset = NULL;
|
||||||
|
|
||||||
nsIURI_AddRef(aURI);
|
nsIURI_AddRef(aURI);
|
||||||
ret->original_uri = aURI;
|
ret->original_uri = aURI;
|
||||||
|
|
Loading…
Reference in New Issue