@oinone/kunlun-vue-admin-base 6.4.11 → 6.4.12

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.
@@ -64790,6 +64790,18 @@ var script$2E = defineComponent({
64790
64790
  * 4. 排除URL前后的标点符号
64791
64791
  */
64792
64792
  const URL_REGEX = /\b(https?:\/\/|ftp:\/\/|sftp:\/\/)([^\s<>"]+)(\.[a-zA-Z0-9]{2,10})([^\s<>"]*)?\b/g;
64793
+ const escapeHtml = (value) => {
64794
+ return value
64795
+ .replace(/&/g, '&amp;')
64796
+ .replace(/</g, '&lt;')
64797
+ .replace(/>/g, '&gt;')
64798
+ .replace(/"/g, '&quot;')
64799
+ .replace(/'/g, '&#039;');
64800
+ };
64801
+ const stringifyJsonText = (value) => {
64802
+ var _a;
64803
+ return escapeHtml((_a = JSON.stringify(value)) !== null && _a !== void 0 ? _a : String(value));
64804
+ };
64793
64805
  /**
64794
64806
  * 将JSON对象解析为带语法高亮和链接的HTML行数据
64795
64807
  * @param obj 要解析的JSON对象
@@ -64804,13 +64816,21 @@ var script$2E = defineComponent({
64804
64816
  * @returns 处理后的HTML字符串
64805
64817
  */
64806
64818
  const replaceUrlWithLink = (str) => {
64807
- // 先通过JSON.stringify转义,再替换URL
64808
- const escapedStr = JSON.stringify(str).slice(1, -1); // 去掉首尾的引号
64809
- return escapedStr.replace(URL_REGEX, (match) => {
64810
- // 对匹配到的URL进行转义,防止XSS
64811
- const encodedUrl = encodeURI(match);
64812
- return `<a href="${encodedUrl}" target="_blank" class="text-blue-500 underline hover:text-blue-700">${match}</a>`;
64813
- });
64819
+ // 先通过JSON.stringify处理JSON转义,再对要注入v-html的文本做HTML转义。
64820
+ const stringifiedStr = JSON.stringify(str).slice(1, -1);
64821
+ let result = '';
64822
+ let lastIndex = 0;
64823
+ let matchResult;
64824
+ URL_REGEX.lastIndex = 0;
64825
+ matchResult = URL_REGEX.exec(stringifiedStr);
64826
+ while (matchResult) {
64827
+ const url = matchResult[0];
64828
+ result += escapeHtml(stringifiedStr.slice(lastIndex, matchResult.index));
64829
+ result += `<a href="${escapeHtml(encodeURI(url))}" target="_blank" class="text-blue-500 underline hover:text-blue-700">${escapeHtml(url)}</a>`;
64830
+ lastIndex = matchResult.index + url.length;
64831
+ matchResult = URL_REGEX.exec(stringifiedStr);
64832
+ }
64833
+ return result + escapeHtml(stringifiedStr.slice(lastIndex));
64814
64834
  };
64815
64835
  if (Array.isArray(obj)) {
64816
64836
  lines.push({
@@ -64834,7 +64854,7 @@ var script$2E = defineComponent({
64834
64854
  }
64835
64855
  else {
64836
64856
  // 非字符串类型:直接JSON.stringify
64837
- itemHtml = `<span class="text-green-600">${JSON.stringify(item)}</span>`;
64857
+ itemHtml = `<span class="text-green-600">${stringifyJsonText(item)}</span>`;
64838
64858
  }
64839
64859
  // 添加逗号
64840
64860
  itemHtml += isLast ? '' : '<span class="text-gray-600">,</span>';
@@ -64874,11 +64894,11 @@ var script$2E = defineComponent({
64874
64894
  // 处理嵌套对象/数组
64875
64895
  lines.push({
64876
64896
  indent: indent + 1,
64877
- html: `<span class="text-blue-600">"${key}"</span><span class="text-gray-600">: </span>`,
64897
+ html: `<span class="text-blue-600">${stringifyJsonText(key)}</span><span class="text-gray-600">: </span>`,
64878
64898
  collapsible: false
64879
64899
  });
64880
64900
  const childLines = parseJSON(value, indent + 1);
64881
- childLines[0].html = `<span class="text-blue-600">"${key}"</span><span class="text-gray-600">: </span>${childLines[0].html}`;
64901
+ childLines[0].html = `<span class="text-blue-600">${stringifyJsonText(key)}</span><span class="text-gray-600">: </span>${childLines[0].html}`;
64882
64902
  childLines[childLines.length - 1].html += isLast ? '' : '<span class="text-gray-600">,</span>';
64883
64903
  lines.pop();
64884
64904
  lines.push(...childLines);
@@ -64893,12 +64913,12 @@ var script$2E = defineComponent({
64893
64913
  }
64894
64914
  else {
64895
64915
  // 非字符串类型:直接序列化
64896
- valueHtml = JSON.stringify(value);
64916
+ valueHtml = stringifyJsonText(value);
64897
64917
  }
64898
64918
  // 拼接最终HTML
64899
64919
  lines.push({
64900
64920
  indent: indent + 1,
64901
- html: `<span class="text-blue-600">"${key}"</span><span class="text-gray-600">: </span><span class="${valueColor}">${valueHtml}</span>${isLast ? '' : '<span class="text-gray-600">,</span>'}`,
64921
+ html: `<span class="text-blue-600">${stringifyJsonText(key)}</span><span class="text-gray-600">: </span><span class="${valueColor}">${valueHtml}</span>${isLast ? '' : '<span class="text-gray-600">,</span>'}`,
64902
64922
  collapsible: false
64903
64923
  });
64904
64924
  }
@@ -64936,12 +64956,7 @@ var script$2E = defineComponent({
64936
64956
  const isOpenTag = trimmed.startsWith('<') && !trimmed.startsWith('</') && !trimmed.endsWith('/>');
64937
64957
  const regx = /<[^/]*?>/g;
64938
64958
  const closeAble = regx.test(line);
64939
- const lineHtml = line
64940
- .replace(/&/g, '&amp;')
64941
- .replace(/</g, '&lt;')
64942
- .replace(/>/g, '&gt;')
64943
- .replace(/"/g, '&quot;')
64944
- .replace(/'/g, '&#039;');
64959
+ const lineHtml = escapeHtml(line);
64945
64960
  lines.push({
64946
64961
  indent,
64947
64962
  html: `<pre>${lineHtml}</pre>`,
@@ -64957,7 +64972,7 @@ var script$2E = defineComponent({
64957
64972
  const lines = [];
64958
64973
  lines.push({
64959
64974
  indent: 1,
64960
- html: `<span class="text-gray-600">${str}</span>`,
64975
+ html: `<span class="text-gray-600">${escapeHtml(str)}</span>`,
64961
64976
  collapsible: false
64962
64977
  });
64963
64978
  return lines;