mirror of
https://github.com/Ylianst/MeshAgent
synced 2025-12-15 15:53:55 +00:00
1. Fixed agent installer to correctly encode JSON when non ascii characters used
2. Fixed agent installer to correctly detect installPath in options
This commit is contained in:
File diff suppressed because one or more lines are too long
@@ -287,29 +287,30 @@ void ILibDuktape_SimpleDataStore_raw_GetCachedValues_Array_sink(ILibSimpleDataSt
|
||||
duk_dup(ctx, -2); // [array][key][obj][key]
|
||||
duk_push_lstring(ctx, Value, ValueLen); // [array][key][obj][key][value]
|
||||
duk_put_prop(ctx, -3); // [array][key][obj]
|
||||
duk_json_encode(ctx, -1); // [array][key][json]
|
||||
duk_size_t len;
|
||||
char *json = (char*)duk_get_lstring(ctx, -1, &len);
|
||||
int colon = ILibString_IndexOf(json, len, ":", 1);
|
||||
duk_json_encode(ctx, -1); // [array][key][json] {"foo": "bar"}
|
||||
duk_size_t len = duk_get_length(ctx, -1);
|
||||
duk_prepare_method_call(ctx, -1, "indexOf"); // [array][key][json][indexOf][this]
|
||||
duk_push_string(ctx, ":"); // [array][key][json][indexOf][this][:]
|
||||
duk_call_method(ctx, 1); // [array][key][json][x]
|
||||
duk_prepare_method_call(ctx, -2, "substring"); // [array][key][json][x][substring][this]
|
||||
duk_push_int(ctx, duk_get_int(ctx, -3) + 1); // [array][key][json][x][substring][this][start]
|
||||
duk_push_uint(ctx, (duk_uint_t)len - 1); // [array][key][json][x][substring][this][start][length]
|
||||
duk_call_method(ctx, 2); // [array][key][json][x][value]
|
||||
duk_push_sprintf(ctx, "--%s=%s", duk_get_string(ctx, -4), duk_get_string(ctx, -1)); //][string]
|
||||
duk_array_push(ctx, -6); // [array][key][json][x][value]
|
||||
duk_pop_n(ctx, 4); // [array]
|
||||
}
|
||||
|
||||
duk_string_substring(ctx, -1, colon+1, (int)len - 1); // [array][key][json][val]
|
||||
char *val = (char*)duk_get_lstring(ctx, -1, &len);
|
||||
|
||||
duk_push_sprintf(ctx, "--%s=%s", k2, val); // [array][key][json][val][string]
|
||||
duk_array_push(ctx, -5); // [array][key][json][val]
|
||||
|
||||
duk_pop_3(ctx); // [array]
|
||||
void ILibDuktape_SimpleDataStore_raw_GetCachedValues_Object(duk_context *ctx, ILibSimpleDataStore dataStore)
|
||||
{
|
||||
duk_push_object(ctx);
|
||||
ILibSimpleDataStore_Cached_GetValues(dataStore, ILibDuktape_SimpleDataStore_raw_GetCachedValues_Object_sink, ctx);
|
||||
}
|
||||
void ILibDuktape_SimpleDataStore_raw_GetCachedValues_Array(duk_context *ctx, ILibSimpleDataStore dataStore)
|
||||
{
|
||||
duk_push_array(ctx);
|
||||
ILibSimpleDataStore_Cached_GetValues(dataStore, ILibDuktape_SimpleDataStore_raw_GetCachedValues_Array_sink, ctx);
|
||||
}
|
||||
void ILibDuktape_SimpleDataStore_raw_GetCachedValues_Object(duk_context *ctx, ILibSimpleDataStore dataStore)
|
||||
{
|
||||
duk_push_object(ctx);
|
||||
ILibSimpleDataStore_Cached_GetValues(dataStore, ILibDuktape_SimpleDataStore_raw_GetCachedValues_Object_sink, ctx);
|
||||
}
|
||||
|
||||
#ifdef __DOXY__
|
||||
/*!
|
||||
|
||||
@@ -65,6 +65,15 @@ Object.defineProperty(Array.prototype, 'deleteParameter',
|
||||
}
|
||||
}
|
||||
});
|
||||
Object.defineProperty(Array.prototype, 'getParameterValue',
|
||||
{
|
||||
value: function (i)
|
||||
{
|
||||
var ret = this[i].substring(this[i].indexOf('=')+1);
|
||||
if (ret.startsWith('"')) { ret = ret.substring(1, ret.length - 1); }
|
||||
return (ret);
|
||||
}
|
||||
});
|
||||
|
||||
function checkParameters(parms)
|
||||
{
|
||||
@@ -175,23 +184,16 @@ function installService(params)
|
||||
}
|
||||
}
|
||||
|
||||
for (i = 0; i < options.parameters.length; ++i)
|
||||
if ((i = options.parameters.getParameterIndex('installPath')) >= 0)
|
||||
{
|
||||
if(options.parameters[i].startsWith('--installPath='))
|
||||
{
|
||||
options.installPath = options.parameters[i].split('=')[1];
|
||||
if (options.installPath.startsWith('"')) { options.installPath = options.installPath.substring(1, options.installPath.length - 1); }
|
||||
options.parameters.splice(i, 1);
|
||||
options.installInPlace = false;
|
||||
break;
|
||||
}
|
||||
if (options.parameters[i].startsWith('--companyName='))
|
||||
{
|
||||
options.companyName = options.parameters[i].split('=')[1];
|
||||
if (options.companyName.startsWith('"')) { options.companyName = options.companyName.substring(1, options.companyName.length - 1); }
|
||||
options.parameters.splice(i, 1);
|
||||
break;
|
||||
}
|
||||
options.installPath = options.parameters.getParameterValue(i);
|
||||
options.installInPlace = false;
|
||||
options.parameters.splice(i, 1);
|
||||
}
|
||||
if ((i = options.parameters.getParameterIndex('companyName')) >= 0)
|
||||
{
|
||||
options.companyName = options.parameters.getParameterValue(i);
|
||||
options.parameters.splice(i, 1);
|
||||
}
|
||||
|
||||
try
|
||||
|
||||
Reference in New Issue
Block a user