зеркало из https://github.com/Azure/iisnode.git
fixed #85 bug in handling appSettings with empty values and duplicated appSetting keys
This commit is contained in:
Родитель
43ad0a87ad
Коммит
ba2a943709
|
@ -69,7 +69,7 @@ HRESULT CModuleConfiguration::CreateNodeEnvironment(IHttpContext* ctx, DWORD deb
|
|||
VARIANT vKeyPropertyName;
|
||||
VARIANT vValuePropertyName;
|
||||
DWORD count;
|
||||
BSTR propertyValue;
|
||||
BSTR propertyValue = NULL;
|
||||
int propertySize;
|
||||
|
||||
CheckNull(env);
|
||||
|
@ -133,22 +133,40 @@ HRESULT CModuleConfiguration::CreateNodeEnvironment(IHttpContext* ctx, DWORD deb
|
|||
|
||||
CheckError(properties->get_Item(vKeyPropertyName, &prop));
|
||||
CheckError(prop->get_StringValue(&propertyValue));
|
||||
ErrorIf(0 == (propertySize = WideCharToMultiByte(CP_ACP, 0, propertyValue, wcslen(propertyValue), NULL, 0, NULL, NULL)), E_FAIL);
|
||||
ErrorIf((propertySize + 2) > (tmpSize - (tmpStart - tmpIndex)), ERROR_NOT_ENOUGH_MEMORY);
|
||||
ErrorIf(propertySize != WideCharToMultiByte(CP_ACP, 0, propertyValue, wcslen(propertyValue), tmpIndex, propertySize, NULL, NULL), E_FAIL);
|
||||
tmpIndex[propertySize] = '=';
|
||||
tmpIndex += propertySize + 1;
|
||||
SysFreeString(propertyValue);
|
||||
propertyValue = NULL;
|
||||
prop->Release();
|
||||
prop = NULL;
|
||||
if (L'\0' != *propertyValue)
|
||||
{
|
||||
// the name of the setting is non-empty
|
||||
|
||||
ErrorIf(0 == (propertySize = WideCharToMultiByte(CP_ACP, 0, propertyValue, wcslen(propertyValue), NULL, 0, NULL, NULL)), E_FAIL);
|
||||
ErrorIf((propertySize + 2) > (tmpSize - (tmpStart - tmpIndex)), ERROR_NOT_ENOUGH_MEMORY);
|
||||
ErrorIf(propertySize != WideCharToMultiByte(CP_ACP, 0, propertyValue, wcslen(propertyValue), tmpIndex, propertySize, NULL, NULL), E_FAIL);
|
||||
tmpIndex[propertySize] = '=';
|
||||
tmpIndex += propertySize + 1;
|
||||
SysFreeString(propertyValue);
|
||||
propertyValue = NULL;
|
||||
prop->Release();
|
||||
prop = NULL;
|
||||
|
||||
CheckError(properties->get_Item(vValuePropertyName, &prop));
|
||||
CheckError(prop->get_StringValue(&propertyValue));
|
||||
if (L'\0' != *propertyValue)
|
||||
{
|
||||
// the value of the property is non-empty
|
||||
|
||||
ErrorIf(0 == (propertySize = WideCharToMultiByte(CP_ACP, 0, propertyValue, wcslen(propertyValue), NULL, 0, NULL, NULL)), E_FAIL);
|
||||
ErrorIf((propertySize + 1) > (tmpSize - (tmpStart - tmpIndex)), ERROR_NOT_ENOUGH_MEMORY);
|
||||
ErrorIf(propertySize != WideCharToMultiByte(CP_ACP, 0, propertyValue, wcslen(propertyValue), tmpIndex, propertySize, NULL, NULL), E_FAIL);
|
||||
tmpIndex += propertySize + 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
// zero-terminate the environment variable of the form "foo=" (i.e. without a value)
|
||||
|
||||
*tmpIndex = L'\0';
|
||||
tmpIndex++;
|
||||
}
|
||||
}
|
||||
|
||||
CheckError(properties->get_Item(vValuePropertyName, &prop));
|
||||
CheckError(prop->get_StringValue(&propertyValue));
|
||||
ErrorIf(0 == (propertySize = WideCharToMultiByte(CP_ACP, 0, propertyValue, wcslen(propertyValue), NULL, 0, NULL, NULL)), E_FAIL);
|
||||
ErrorIf((propertySize + 1) > (tmpSize - (tmpStart - tmpIndex)), ERROR_NOT_ENOUGH_MEMORY);
|
||||
ErrorIf(propertySize != WideCharToMultiByte(CP_ACP, 0, propertyValue, wcslen(propertyValue), tmpIndex, propertySize, NULL, NULL), E_FAIL);
|
||||
tmpIndex += propertySize + 1;
|
||||
SysFreeString(propertyValue);
|
||||
propertyValue = NULL;
|
||||
prop->Release();
|
||||
|
|
|
@ -2,5 +2,5 @@ var http = require('http');
|
|||
|
||||
http.createServer(function (req, res) {
|
||||
res.writeHead(200, {'Content-Type': 'text/html'});
|
||||
res.end('' + process.env.setting1 + process.env.setting2);
|
||||
res.end('' + process.env.setting1 + process.env.setting2 + process.env.setting3);
|
||||
}).listen(process.env.PORT);
|
|
@ -3,6 +3,8 @@
|
|||
<appSettings>
|
||||
<add key="setting1" value="value1" />
|
||||
<add key="setting2" value="value2" />
|
||||
<add key="" value="emptyKey"/>
|
||||
<add key="setting3" value="" />
|
||||
</appSettings>
|
||||
|
||||
<system.webServer>
|
||||
|
|
Загрузка…
Ссылка в новой задаче