diff --git a/CHANGELOG.md b/CHANGELOG.md index cd5e76121..a7c4fe92e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,11 @@ # Snyk Security - Code and Open Source Dependencies Changelog +## [2.2.3] + +### Fixed + +- Snyk Code: Added `isExampleLineEncoded` boolean flag to `CommitChangeLine` type to prevent re-encoding strings in the UI of the example code blocks. + ## [2.2.2] ### Fixed diff --git a/src/snyk/common/languageServer/types.ts b/src/snyk/common/languageServer/types.ts index d659a9512..254b91656 100644 --- a/src/snyk/common/languageServer/types.ts +++ b/src/snyk/common/languageServer/types.ts @@ -58,6 +58,7 @@ type CommitChangeLine = { line: string; lineNumber: number; lineChange: 'removed' | 'added' | 'none'; + isExampleLineEncoded?: boolean; }; export type Marker = { msg: Point; diff --git a/src/snyk/snykCode/utils/htmlEncoder.ts b/src/snyk/snykCode/utils/htmlEncoder.ts index c17f4d94a..046d7f499 100644 --- a/src/snyk/snykCode/utils/htmlEncoder.ts +++ b/src/snyk/snykCode/utils/htmlEncoder.ts @@ -2,14 +2,19 @@ import he from 'he'; import { ExampleCommitFix } from '../../common/languageServer/types'; export const encodeExampleCommitFixes = (exampleCommitFixes: ExampleCommitFix[]): ExampleCommitFix[] => { - return exampleCommitFixes.map(exampleCommitFixes => { + return exampleCommitFixes.map(example => { return { - ...exampleCommitFixes, - lines: exampleCommitFixes.lines.map(line => { - return { - ...line, - line: he.encode(line.line), - }; + ...example, + lines: example.lines.map(commitLine => { + if (!commitLine.isExampleLineEncoded) { + return { + ...commitLine, + line: he.encode(commitLine.line), + isExampleLineEncoded: true, + }; + } + + return commitLine; }), }; }); diff --git a/src/snyk/snykCode/views/suggestion/codeSuggestionWebviewScript.ts b/src/snyk/snykCode/views/suggestion/codeSuggestionWebviewScript.ts index 3b523bffb..b6c79d245 100644 --- a/src/snyk/snykCode/views/suggestion/codeSuggestionWebviewScript.ts +++ b/src/snyk/snykCode/views/suggestion/codeSuggestionWebviewScript.ts @@ -27,6 +27,7 @@ declare const acquireVsCodeApi: any; line: string; lineNumber: number; lineChange: 'removed' | 'added' | 'none'; + isExampleLineEncoded?: boolean; }; type Marker = { msg: Point;