mirror of
git://source.winehq.org/git/wine.git
synced 2024-11-02 01:21:47 +00:00
xmllite/writer: Validate local name and prefix in WriteStartElement().
Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com> Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
parent
69b2ed368d
commit
b34362f2d9
2 changed files with 18 additions and 5 deletions
|
@ -858,8 +858,8 @@ static void test_WriteStartElement(void)
|
||||||
{
|
{
|
||||||
{ "prefix", "local", "uri", "<prefix:local xmlns:prefix=\"uri\" />", "<prefix:local", S_OK, 1 },
|
{ "prefix", "local", "uri", "<prefix:local xmlns:prefix=\"uri\" />", "<prefix:local", S_OK, 1 },
|
||||||
{ NULL, "local", "uri", "<local xmlns=\"uri\" />", "<local", S_OK, 1 },
|
{ NULL, "local", "uri", "<local xmlns=\"uri\" />", "<local", S_OK, 1 },
|
||||||
{ "", "local", "uri", "<local xmlns=\"uri\" />", "<local", S_OK, 1, 1 },
|
{ "", "local", "uri", "<local xmlns=\"uri\" />", "<local", S_OK, 1 },
|
||||||
{ "", "local", "uri", "<local xmlns=\"uri\" />", "<local", S_OK, 1, 1},
|
{ "", "local", "uri", "<local xmlns=\"uri\" />", "<local", S_OK, 1 },
|
||||||
|
|
||||||
{ "prefix", NULL, NULL, NULL, NULL, E_INVALIDARG },
|
{ "prefix", NULL, NULL, NULL, NULL, E_INVALIDARG },
|
||||||
{ NULL, NULL, "uri", NULL, NULL, E_INVALIDARG },
|
{ NULL, NULL, "uri", NULL, NULL, E_INVALIDARG },
|
||||||
|
@ -953,7 +953,7 @@ static void test_WriteStartElement(void)
|
||||||
uriW = strdupAtoW(start_element_tests[i].uri);
|
uriW = strdupAtoW(start_element_tests[i].uri);
|
||||||
|
|
||||||
hr = IXmlWriter_WriteStartElement(writer, prefixW, localW, uriW);
|
hr = IXmlWriter_WriteStartElement(writer, prefixW, localW, uriW);
|
||||||
todo_wine_if(i >= 7)
|
todo_wine_if(i >= 11)
|
||||||
ok(hr == start_element_tests[i].hr, "%u: unexpected hr %#x.\n", i, hr);
|
ok(hr == start_element_tests[i].hr, "%u: unexpected hr %#x.\n", i, hr);
|
||||||
|
|
||||||
if (SUCCEEDED(start_element_tests[i].hr))
|
if (SUCCEEDED(start_element_tests[i].hr))
|
||||||
|
|
|
@ -20,7 +20,9 @@
|
||||||
*/
|
*/
|
||||||
#define COBJMACROS
|
#define COBJMACROS
|
||||||
|
|
||||||
|
#include <assert.h>
|
||||||
#include <stdarg.h>
|
#include <stdarg.h>
|
||||||
|
|
||||||
#include "windef.h"
|
#include "windef.h"
|
||||||
#include "winbase.h"
|
#include "winbase.h"
|
||||||
#include "objbase.h"
|
#include "objbase.h"
|
||||||
|
@ -296,7 +298,9 @@ static HRESULT write_output_buffer_quoted(xmlwriteroutput *output, const WCHAR *
|
||||||
static HRESULT write_output_qname(xmlwriteroutput *output, const WCHAR *prefix, int prefix_len,
|
static HRESULT write_output_qname(xmlwriteroutput *output, const WCHAR *prefix, int prefix_len,
|
||||||
const WCHAR *local_name, int local_len)
|
const WCHAR *local_name, int local_len)
|
||||||
{
|
{
|
||||||
if (prefix) {
|
assert(prefix_len >= 0 && local_len >= 0);
|
||||||
|
|
||||||
|
if (prefix_len) {
|
||||||
static const WCHAR colW[] = {':'};
|
static const WCHAR colW[] = {':'};
|
||||||
write_output_buffer(output, prefix, prefix_len);
|
write_output_buffer(output, prefix, prefix_len);
|
||||||
write_output_buffer(output, colW, ARRAY_SIZE(colW));
|
write_output_buffer(output, colW, ARRAY_SIZE(colW));
|
||||||
|
@ -1253,7 +1257,9 @@ static HRESULT WINAPI xmlwriter_WriteStartDocument(IXmlWriter *iface, XmlStandal
|
||||||
static HRESULT WINAPI xmlwriter_WriteStartElement(IXmlWriter *iface, LPCWSTR prefix, LPCWSTR local_name, LPCWSTR uri)
|
static HRESULT WINAPI xmlwriter_WriteStartElement(IXmlWriter *iface, LPCWSTR prefix, LPCWSTR local_name, LPCWSTR uri)
|
||||||
{
|
{
|
||||||
xmlwriter *This = impl_from_IXmlWriter(iface);
|
xmlwriter *This = impl_from_IXmlWriter(iface);
|
||||||
|
int prefix_len, local_len;
|
||||||
struct element *element;
|
struct element *element;
|
||||||
|
HRESULT hr;
|
||||||
|
|
||||||
TRACE("(%p)->(%s %s %s)\n", This, wine_dbgstr_w(prefix), wine_dbgstr_w(local_name), wine_dbgstr_w(uri));
|
TRACE("(%p)->(%s %s %s)\n", This, wine_dbgstr_w(prefix), wine_dbgstr_w(local_name), wine_dbgstr_w(uri));
|
||||||
|
|
||||||
|
@ -1272,6 +1278,13 @@ static HRESULT WINAPI xmlwriter_WriteStartElement(IXmlWriter *iface, LPCWSTR pre
|
||||||
;
|
;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Validate prefix and local name */
|
||||||
|
if (FAILED(hr = is_valid_ncname(prefix, &prefix_len)))
|
||||||
|
return hr;
|
||||||
|
|
||||||
|
if (FAILED(hr = is_valid_ncname(local_name, &local_len)))
|
||||||
|
return hr;
|
||||||
|
|
||||||
/* close pending element */
|
/* close pending element */
|
||||||
if (This->starttagopen)
|
if (This->starttagopen)
|
||||||
write_output_buffer(This->output, gtW, ARRAY_SIZE(gtW));
|
write_output_buffer(This->output, gtW, ARRAY_SIZE(gtW));
|
||||||
|
@ -1289,7 +1302,7 @@ static HRESULT WINAPI xmlwriter_WriteStartElement(IXmlWriter *iface, LPCWSTR pre
|
||||||
push_element(This, element);
|
push_element(This, element);
|
||||||
|
|
||||||
write_output_buffer(This->output, ltW, ARRAY_SIZE(ltW));
|
write_output_buffer(This->output, ltW, ARRAY_SIZE(ltW));
|
||||||
write_output_qname(This->output, prefix, -1, local_name, -1);
|
write_output_qname(This->output, prefix, prefix_len, local_name, local_len);
|
||||||
writer_inc_indent(This);
|
writer_inc_indent(This);
|
||||||
|
|
||||||
return S_OK;
|
return S_OK;
|
||||||
|
|
Loading…
Reference in a new issue