dolphindb 3.0.103 → 3.0.105

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/browser.d.ts CHANGED
@@ -411,7 +411,7 @@ export interface ConvertOptions {
411
411
  /** timestamp 类型转换为字符串表示时显示到秒还是毫秒 */
412
412
  timestamp?: 's' | 'ms';
413
413
  }
414
- export declare function convert(type: DdbType, value: DdbValue, le: boolean, { blob, timestamp }?: ConvertOptions): string | number | bigint | boolean | Uint8Array | DdbFunctionDefValue | DdbDurationValue | DdbDecimal32Value | DdbDecimal64Value | DdbDecimal32VectorValue | Int32Array | DdbDecimal64VectorValue | BigInt64Array | DdbDecimal128VectorValue | BigInt128Array | DdbSymbolExtendedValue | string[] | Int8Array | Int16Array | Float32Array | Float64Array | DdbArrayVectorValue | DdbMatrixValue | Uint8Array[] | DdbObj<DdbValue>[] | DdbDurationVectorValue | number[] | DdbTensorValue | DdbChartValue;
414
+ export declare function convert(type: DdbType, value: DdbValue, le: boolean, { blob, timestamp }?: ConvertOptions): string | number | bigint | boolean | Uint8Array | number[] | DdbFunctionDefValue | DdbDurationValue | DdbDecimal32Value | DdbDecimal64Value | Int8Array | Int16Array | Int32Array | Float32Array | Float64Array | BigInt64Array | BigInt128Array | string[] | Uint8Array[] | DdbObj<DdbValue>[] | DdbSymbolExtendedValue | DdbArrayVectorValue | DdbDecimal32VectorValue | DdbDecimal64VectorValue | DdbDecimal128VectorValue | DdbDurationVectorValue | DdbMatrixValue | DdbChartValue | DdbTensorValue;
415
415
  /** 转换一个向量到 js 原生数组 */
416
416
  export declare function converts(type: DdbType, value: DdbVectorValue, rows: number, le: boolean, options?: ConvertOptions): any[];
417
417
  export declare class DdbVoid extends DdbObj<undefined> {
package/browser.js CHANGED
@@ -968,6 +968,7 @@ export class DdbObj {
968
968
  case DdbType.handle:
969
969
  case DdbType.datasource:
970
970
  case DdbType.resource:
971
+ assert(!value.includes('\0'), t('pack 时字符串中间不能含有 \\0, 否则上传给 DolphinDB 会导致连接断开'));
971
972
  return [
972
973
  DdbObj.enc.encode(value),
973
974
  Uint8Array.of(0),
@@ -1144,7 +1145,9 @@ export class DdbObj {
1144
1145
  case DdbType.code: {
1145
1146
  let bufs = new Array(length * 2);
1146
1147
  for (let i = 0; i < length; i++) {
1147
- bufs[2 * i] = this.enc.encode(value[i]);
1148
+ const s = value[i];
1149
+ assert(!s.includes('\0'), t('pack 时字符串中间不能含有 \\0, 否则上传给 DolphinDB 会导致连接断开'));
1150
+ bufs[2 * i] = this.enc.encode(s);
1148
1151
  bufs[2 * i + 1] = Uint8Array.of(0);
1149
1152
  }
1150
1153
  return bufs;
@@ -2999,6 +3002,7 @@ export class DDB {
2999
3002
  case 'function':
3000
3003
  if (this.verbose)
3001
3004
  console.log(func + args.map(arg => arg.toString()).join(', ').bracket() + rpc_id);
3005
+ assert(!func.includes('\0'), t('发送至 DolphinDB 执行的脚本中间不能含有 \\0'));
3002
3006
  return 'function\n' +
3003
3007
  `${func}\n` +
3004
3008
  `${args.length}\n` +
@@ -3006,6 +3010,7 @@ export class DDB {
3006
3010
  case 'script':
3007
3011
  if (this.verbose)
3008
3012
  console.log(script + rpc_id);
3013
+ assert(!script.includes('\0'), t('发送至 DolphinDB 执行的脚本中间不能含有 \\0'));
3009
3014
  return 'script\n' +
3010
3015
  script;
3011
3016
  case 'variable':