From 90bd57fe40e66fc829ecb01482d32d604b0df19c Mon Sep 17 00:00:00 2001 From: Mounir IDRASSI Date: Wed, 25 Nov 2015 01:41:37 +0100 Subject: Windows: Full UNICODE rewrite and implement support for UNICODE passwords. --- src/Common/Xml.c | 53 +++++++++++++++++++++++++++++++++++++++++++---------- 1 file changed, 43 insertions(+), 10 deletions(-) (limited to 'src/Common/Xml.c') diff --git a/src/Common/Xml.c b/src/Common/Xml.c index bd01460b..71994510 100644 --- a/src/Common/Xml.c +++ b/src/Common/Xml.c @@ -210,26 +210,59 @@ char *XmlQuoteText (const char *textSrc, char *textDst, int textDstMaxSize) return textDst; } - -int XmlWriteHeader (FILE *file) +wchar_t *XmlQuoteTextW (const wchar_t *textSrc, wchar_t *textDst, int textDstMaxSize) { - return fputs ("\n", file); -} + wchar_t *textDstLast = textDst + textDstMaxSize - 1; + if (textDstMaxSize == 0) + return NULL; -int XmlWriteHeaderW (FILE *file) -{ - return fputws (L"\n", file); + while (*textSrc != 0 && textDst <= textDstLast) + { + wchar_t c = *textSrc++; + switch (c) + { + case L'&': + if (textDst + 6 > textDstLast) + return NULL; + wcscpy (textDst, L"&"); + textDst += 5; + continue; + + case L'>': + if (textDst + 5 > textDstLast) + return NULL; + wcscpy (textDst, L">"); + textDst += 4; + continue; + + case L'<': + if (textDst + 5 > textDstLast) + return NULL; + wcscpy (textDst, L"<"); + textDst += 4; + continue; + + default: + *textDst++ = c; + } + } + + if (textDst > textDstLast) + return NULL; + + *textDst = 0; + return textDst; } -int XmlWriteFooter (FILE *file) +int XmlWriteHeader (FILE *file) { - return fputs ("\n", file); + return fputws (L"\n", file); } -int XmlWriteFooterW (FILE *file) +int XmlWriteFooter (FILE *file) { return fputws (L"\n", file); } -- cgit v1.2.3