Commit ae2057cb authored by Nikolay Sivov's avatar Nikolay Sivov Committed by Alexandre Julliard

msxml3: Clean formatting chars before passing to base64 decoder.

parent 1d796741
......@@ -459,7 +459,7 @@ static inline BYTE base64_to_byte(xmlChar c)
return c-'a'+26;
}
static inline HRESULT VARIANT_from_DT(XDR_DT dt, xmlChar* str, VARIANT* v)
static inline HRESULT variant_from_dt(XDR_DT dt, xmlChar* str, VARIANT* v)
{
VARIANT src;
HRESULT hr = S_OK;
......@@ -571,9 +571,25 @@ static inline HRESULT VARIANT_from_DT(XDR_DT dt, xmlChar* str, VARIANT* v)
case DT_BIN_BASE64:
{
SAFEARRAYBOUND sab;
xmlChar *c1, *c2;
int i, len;
len = xmlStrlen(str);
/* remove all formatting chars */
c1 = c2 = str;
len = 0;
while (*c2)
{
if ( *c2 == ' ' || *c2 == '\t' ||
*c2 == '\n' || *c2 == '\r' )
{
c2++;
continue;
}
*c1++ = *c2++;
len++;
}
/* skip padding */
if(str[len-2] == '=') i = 2;
else if(str[len-1] == '=') i = 1;
else i = 0;
......@@ -719,23 +735,22 @@ static XDR_DT element_get_dt(xmlNodePtr node)
static HRESULT WINAPI domelem_get_nodeTypedValue(
IXMLDOMElement *iface,
VARIANT* var1)
VARIANT* v)
{
domelem *This = impl_from_IXMLDOMElement( iface );
XDR_DT dt;
xmlChar* content;
HRESULT hr;
TRACE("(%p)->(%p)\n", This, var1);
TRACE("(%p)->(%p)\n", This, v);
if(!var1)
return E_INVALIDARG;
if(!v) return E_INVALIDARG;
V_VT(var1) = VT_NULL;
V_VT(v) = VT_NULL;
dt = element_get_dt(get_element(This));
content = xmlNodeGetContent(get_element(This));
hr = VARIANT_from_DT(dt, content, var1);
hr = variant_from_dt(dt, content, v);
xmlFree(content);
return hr;
......
......@@ -373,6 +373,8 @@ static const CHAR szTypeValueXML[] =
" <uuid dt:dt=\"uuid\">333C7BC4-460F-11D0-BC04-0080C7055a83</uuid>\n"
" <binhex dt:dt=\"bin.hex\">fffca012003c</binhex>\n"
" <binbase64 dt:dt=\"bin.base64\">YmFzZTY0IHRlc3Q=</binbase64>\n"
" <binbase64_1 dt:dt=\"bin.base64\">\nYmFzZTY0\nIHRlc3Q=\n</binbase64_1>\n"
" <binbase64_2 dt:dt=\"bin.base64\">\nYmF\r\t z ZTY0\nIHRlc3Q=\n</binbase64_2>\n"
"</root>";
static const CHAR szBasicTransformSSXMLPart1[] =
......@@ -5867,6 +5869,9 @@ static const nodetypedvalue_t get_nodetypedvalue[] = {
{ "root/r8", VT_R8, "0.412" },
{ "root/float", VT_R8, "41221.421" },
{ "root/uuid", VT_BSTR, "333C7BC4-460F-11D0-BC04-0080C7055a83" },
{ "root/binbase64", VT_ARRAY|VT_UI1, "base64 test" },
{ "root/binbase64_1", VT_ARRAY|VT_UI1, "base64 test" },
{ "root/binbase64_2", VT_ARRAY|VT_UI1, "base64 test" },
{ 0 }
};
......@@ -5938,21 +5943,6 @@ static void test_nodeTypedValue(void)
IXMLDOMNode_Release(node);
}
hr = IXMLDOMDocument_selectSingleNode(doc, _bstr_("root/binbase64"), &node);
ok(hr == S_OK, "ret %08x\n", hr );
{
BYTE bytes[] = {0x62,0x61,0x73,0x65,0x36,0x34,0x20,0x74,0x65,0x73,0x74};
hr = IXMLDOMNode_get_nodeTypedValue(node, &value);
ok(hr == S_OK, "ret %08x\n", hr );
ok(V_VT(&value) == (VT_ARRAY|VT_UI1), "incorrect type\n");
ok(V_ARRAY(&value)->rgsabound[0].cElements == 11, "incorrect array size\n");
if(V_ARRAY(&value)->rgsabound[0].cElements == 11)
ok(!memcmp(bytes, V_ARRAY(&value)->pvData, sizeof(bytes)), "incorrect value\n");
VariantClear(&value);
IXMLDOMNode_Release(node);
}
hr = IXMLDOMDocument_createProcessingInstruction(doc, _bstr_("foo"), _bstr_("value"), &pi);
ok(hr == S_OK, "ret %08x\n", hr );
{
......@@ -6042,6 +6032,12 @@ static void test_nodeTypedValue(void)
ok(hr == S_OK, "ret %08x\n", hr );
ok(V_VT(&value) == entry->type, "incorrect type, expected %d, got %d\n", entry->type, V_VT(&value));
if (entry->type == (VT_ARRAY|VT_UI1))
{
ok(V_ARRAY(&value)->rgsabound[0].cElements == strlen(entry->value),
"incorrect array size, got %d, expected %d\n", V_ARRAY(&value)->rgsabound[0].cElements, strlen(entry->value));
}
if (entry->type != VT_BSTR)
{
if (entry->type == VT_DATE ||
......@@ -6064,8 +6060,15 @@ static void test_nodeTypedValue(void)
ok(hr == S_OK, "ret %08x\n", hr );
}
ok(lstrcmpW( V_BSTR(&value), _bstr_(entry->value)) == 0,
"expected %s, got %s\n", entry->value, wine_dbgstr_w(V_BSTR(&value)));
/* for byte array from VT_ARRAY|VT_UI1 it's not a WCHAR buffer */
if (entry->type == (VT_ARRAY|VT_UI1))
{
ok(!memcmp( V_BSTR(&value), entry->value, strlen(entry->value)),
"expected %s", entry->value);
}
else
ok(lstrcmpW( V_BSTR(&value), _bstr_(entry->value)) == 0,
"expected %s, got %s\n", entry->value, wine_dbgstr_w(V_BSTR(&value)));
}
else
ok(lstrcmpW( V_BSTR(&value), _bstr_(entry->value)) == 0,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment