From 4efe8ea512e627623f1ede0d1d5bca6c03ee1a60 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=8C=83=E6=99=BA=E9=B9=8F?= Date: Tue, 8 Sep 2026 19:51:29 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=20esc=20=E8=BD=AC?= =?UTF-8?q?=E4=B9=89=20>=20=E8=AF=AF=E5=86=99=E4=B8=BA=20"=20+=20Exce?= =?UTF-8?q?l=20=E8=A1=A8=E5=A4=B4=E9=94=AE=E5=8F=96=E5=85=A8=E8=A1=8C?= =?UTF-8?q?=E5=B9=B6=E9=9B=86=EF=BC=8C=E6=96=B0=E5=A2=9E=2011=20=E4=B8=AA?= =?UTF-8?q?=E5=8D=95=E6=B5=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/panel/webview.ts | 4 +- src/rules/converters/excel-converter.ts | 34 +- tests/coverage/index.html | 122 +-- .../coverage/src/activation/commands.ts.html | 23 +- tests/coverage/src/activation/index.html | 20 +- tests/coverage/src/adapters/eslint.ts.html | 2 +- tests/coverage/src/adapters/index.html | 2 +- tests/coverage/src/adapters/jsp.ts.html | 2 +- tests/coverage/src/adapters/pmd.ts.html | 2 +- tests/coverage/src/adapters/sqlfluff.ts.html | 2 +- tests/coverage/src/adapters/stylelint.ts.html | 2 +- tests/coverage/src/ai/engine.ts.html | 144 ++-- tests/coverage/src/ai/factory.ts.html | 2 +- tests/coverage/src/ai/index.html | 38 +- tests/coverage/src/ai/providers/base.ts.html | 105 ++- .../coverage/src/ai/providers/claude.ts.html | 8 +- .../coverage/src/ai/providers/gemini.ts.html | 6 +- tests/coverage/src/ai/providers/index.html | 24 +- .../ai/providers/openai-compatible.ts.html | 8 +- tests/coverage/src/ai/registry.ts.html | 2 +- tests/coverage/src/config/ai.ts.html | 2 +- tests/coverage/src/config/fixer.ts.html | 2 +- tests/coverage/src/config/index.html | 2 +- tests/coverage/src/config/index.ts.html | 2 +- tests/coverage/src/config/linter.ts.html | 2 +- tests/coverage/src/config/secret.ts.html | 2 +- .../src/diagnostics/diagnosticMarkers.ts.html | 2 +- tests/coverage/src/diagnostics/index.html | 2 +- tests/coverage/src/extension.ts.html | 2 +- tests/coverage/src/fix/aiFixEngine.ts.html | 80 +- .../src/fix/codeActionProvider.ts.html | 2 +- .../coverage/src/fix/customFixEngine.ts.html | 80 +- tests/coverage/src/fix/fixEngine.ts.html | 2 +- tests/coverage/src/fix/fixPending.ts.html | 2 +- tests/coverage/src/fix/fixPreview.ts.html | 2 +- tests/coverage/src/fix/fixPrompt.ts.html | 68 +- tests/coverage/src/fix/fixSession.ts.html | 2 +- tests/coverage/src/fix/index.html | 54 +- tests/coverage/src/i18n/index.html | 2 +- tests/coverage/src/i18n/messages.ts.html | 8 +- tests/coverage/src/index.html | 2 +- tests/coverage/src/jsp/index.html | 2 +- tests/coverage/src/jsp/jsp-extractor.ts.html | 2 +- tests/coverage/src/merger/index.html | 2 +- tests/coverage/src/merger/merger.ts.html | 2 +- tests/coverage/src/orchestrator/index.html | 2 +- .../src/orchestrator/orchestrator.ts.html | 2 +- tests/coverage/src/panel/index.html | 34 +- tests/coverage/src/panel/webview.ts.html | 166 ++-- .../coverage/src/rules/builtin-rules.ts.html | 2 +- .../src/rules/converters/dedup-prompt.ts.html | 2 +- .../rules/converters/docx-converter.ts.html | 2 +- .../rules/converters/excel-converter.ts.html | 146 ++-- .../coverage/src/rules/converters/index.html | 40 +- .../src/rules/converters/known-rules.ts.html | 2 +- .../src/rules/converters/md-converter.ts.html | 2 +- .../rules/converters/pptx-converter.ts.html | 2 +- .../rules/converters/prompt-builder.ts.html | 762 +++++++++--------- .../converters/template-converter.ts.html | 2 +- .../rules/converters/txt-converter.ts.html | 2 +- .../rules/converters/yaml-converter.ts.html | 2 +- .../coverage/src/rules/export-service.ts.html | 2 +- .../coverage/src/rules/import-preview.ts.html | 2 +- .../coverage/src/rules/import-service.ts.html | 2 +- tests/coverage/src/rules/index.html | 2 +- tests/coverage/src/rules/rule-filter.ts.html | 2 +- tests/coverage/src/rules/yaml-parser.ts.html | 2 +- tests/coverage/src/scope/index.html | 2 +- .../src/scope/method-extractor.ts.html | 2 +- tests/coverage/src/scope/status-cache.ts.html | 2 +- .../src/services/auxClasspath.ts.html | 2 +- tests/coverage/src/services/index.html | 2 +- tests/coverage/src/utils/diff.ts.html | 12 +- tests/coverage/src/utils/index.html | 2 +- tests/coverage/src/utils/mockDocument.ts.html | 2 +- tests/coverage/src/utils/report.ts.html | 2 +- .../src/views/codeLensProvider.ts.html | 2 +- tests/coverage/src/views/index.html | 2 +- tests/coverage/src/views/setupView.ts.html | 2 +- tests/excel-converter.test.ts | 88 ++ .../galaxy-team-coding-conventions.xlsx | Bin 0 -> 12488 bytes tests/webview-escape.test.ts | 24 + 82 files changed, 1238 insertions(+), 972 deletions(-) create mode 100644 tests/excel-converter.test.ts create mode 100644 tests/fixtures/galaxy-team-coding-conventions.xlsx create mode 100644 tests/webview-escape.test.ts diff --git a/src/panel/webview.ts b/src/panel/webview.ts index 0d7d1ab..75fdc58 100644 --- a/src/panel/webview.ts +++ b/src/panel/webview.ts @@ -12,8 +12,8 @@ interface PanelMessage { origin?: 'hover' | 'panel'; } -function esc(str: string): string { - return str.replace(/&/g, '&').replace(//g, '"').replace(/"/g, '"'); +export function esc(str: string): string { + return str.replace(/&/g, '&').replace(//g, '>').replace(/"/g, '"'); } function svgIcon(): string { diff --git a/src/rules/converters/excel-converter.ts b/src/rules/converters/excel-converter.ts index e58c354..9d2cbb3 100644 --- a/src/rules/converters/excel-converter.ts +++ b/src/rules/converters/excel-converter.ts @@ -6,8 +6,8 @@ import { buildSystemPrompt } from './prompt-builder'; import type { CustomRule } from '../../types'; import { t } from '../../i18n/messages'; -function buildMarkdownTable(rows: Record[], sheetName: string): string { - const keys = Object.keys(rows[0]); +export function buildMarkdownTable(rows: Record[], sheetName: string): string { + const keys = [...new Set(rows.flatMap(row => Object.keys(row)))]; const header = `| ${keys.join(' | ')} |`; const separator = `| ${keys.map(() => '---').join(' | ')} |`; const dataLines = rows.map(row => { @@ -17,6 +17,20 @@ function buildMarkdownTable(rows: Record[], sheetName: string): return [`## ${sheetName}`, header, separator, ...dataLines].join('\n'); } +export function renderWorkbookToMarkdown(workbook: XLSX.WorkBook): string | null { + const parts: string[] = []; + for (const sheetName of workbook.SheetNames) { + const sheet = workbook.Sheets[sheetName]; + if (!sheet) { continue; } + const rows = XLSX.utils.sheet_to_json>(sheet); + if (rows.length === 0) { + continue; + } + parts.push(buildMarkdownTable(rows, sheetName)); + } + return parts.length === 0 ? null : parts.join('\n\n'); +} + export class ExcelConverter implements RuleConverter { supportedExtensions = ['.xlsx', '.xls']; @@ -35,30 +49,20 @@ export class ExcelConverter implements RuleConverter { return null; } - let parts: string[]; + let combined: string | null; try { - parts = []; - for (const sheetName of workbook.SheetNames) { - const sheet = workbook.Sheets[sheetName]; - if (!sheet) { continue; } - const rows = XLSX.utils.sheet_to_json>(sheet); - if (rows.length === 0) { - continue; - } - parts.push(buildMarkdownTable(rows, sheetName)); - } + combined = renderWorkbookToMarkdown(workbook); } catch (err) { const msg = err instanceof Error ? err.message : String(err); vscode.window.showErrorMessage(t('import.excelReadFail', { 0: msg })); return null; } - if (parts.length === 0) { + if (combined === null) { vscode.window.showErrorMessage(t('import.excelNoData')); return null; } - const combined = parts.join('\n\n'); return convertContentWithAI(combined, context, buildSystemPrompt('spreadsheet', existingRules)); } } diff --git a/tests/coverage/index.html b/tests/coverage/index.html index 1d28e82..14156a8 100644 --- a/tests/coverage/index.html +++ b/tests/coverage/index.html @@ -23,30 +23,30 @@
- 48.24% + 48.55% Statements - 5570/11546 + 5630/11596
- 77.97% + 78.22% Branches - 524/672 + 546/698
- 43.66% + 44.84% Functions - 155/355 + 161/359
- 48.24% + 48.55% Lines - 5570/11546 + 5630/11596
@@ -95,17 +95,17 @@ src/activation - +
- 14.03% - 122/869 + 14.02% + 122/870 100% 1/1 10% 1/10 - 14.03% - 122/869 + 14.02% + 122/870 @@ -125,32 +125,32 @@ src/ai - -
+ +
- 20.52% - 173/843 - 75.86% - 22/29 - 31.03% - 9/29 - 20.52% - 173/843 + 21.76% + 187/859 + 77.14% + 27/35 + 35.48% + 11/31 + 21.76% + 187/859 src/ai/providers - +
- 97.55% - 239/245 - 83.72% - 36/43 + 97.81% + 268/274 + 87.71% + 50/57 100% - 10/10 - 97.55% - 239/245 + 13/13 + 97.81% + 268/274 @@ -185,17 +185,17 @@ src/fix - -
+ +
- 73.11% - 680/930 - 67.48% - 110/163 - 69.38% - 34/49 - 73.11% - 680/930 + 72.04% + 670/930 + 64.51% + 100/155 + 68.08% + 32/47 + 72.04% + 670/930 @@ -260,17 +260,17 @@ src/panel - -
+ +
- 11.88% - 68/572 + 12.41% + 71/572 100% - 2/2 - 10.52% - 2/19 - 11.88% - 68/572 + 3/3 + 15.78% + 3/19 + 12.41% + 71/572 @@ -290,17 +290,17 @@ src/rules/converters - -
+ +
- 72.69% - 647/890 - 92.85% - 13/14 - 34.48% - 10/29 - 72.69% - 647/890 + 75.05% + 671/894 + 92.59% + 25/27 + 40% + 12/30 + 75.05% + 671/894 @@ -371,7 +371,7 @@