Skip to content

Commit 10abf2b

Browse files
committed
PD-263 Remove snippet code encoding.
1 parent 366e17f commit 10abf2b

File tree

4 files changed

+2
-22
lines changed

4 files changed

+2
-22
lines changed

js/types/Snippet.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ export interface Snippet {
1111
shared_network?: boolean | null
1212
modified?: string
1313
code_error?: [string, number] | null
14-
encoded?: boolean
1514
}
1615

1716
export const SNIPPET_SCOPES = <const> [

js/utils/api/snippets.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ import { ExportSnippets } from '../../types/ExportSnippets'
55
import { Snippet } from '../../types/Snippet'
66
import { isNetworkAdmin } from '../general'
77
import { useAxios } from './axios'
8-
import { encodeSnippetCode } from '../snippets'
98

109
const ROUTE_BASE = window.CODE_SNIPPETS?.restAPI.snippets
1110

@@ -42,10 +41,10 @@ export const useSnippetsAPI = (): SnippetsAPI => {
4241
get<Snippet>(addQueryArgs(`${ROUTE_BASE}/${snippetId}`, { network })),
4342

4443
create: snippet =>
45-
post<Snippet, Snippet>(`${ROUTE_BASE}`, encodeSnippetCode(snippet)),
44+
post<Snippet, Snippet>(`${ROUTE_BASE}`, snippet),
4645

4746
update: snippet =>
48-
post<Snippet, Snippet>(buildURL(snippet), encodeSnippetCode(snippet)),
47+
post<Snippet, Snippet>(buildURL(snippet), snippet),
4948

5049
delete: (snippet: Snippet) =>
5150
del(buildURL(snippet)),

js/utils/snippets.ts

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -43,17 +43,3 @@ export const isProType = (type: SnippetType): boolean =>
4343

4444
export const isLicensed = (): boolean =>
4545
!!window.CODE_SNIPPETS?.isLicensed
46-
47-
export const encodeSnippetCode = (snippet: Snippet) => {
48-
const encoded: Record<string, string | undefined> = {
49-
'&': '&amp;',
50-
'<': '&lt;',
51-
'>': '&gt;',
52-
'$': '&#36;'
53-
}
54-
55-
snippet.code = snippet.code.replace(/[&<>$]/g, match => encoded[match] ?? match)
56-
snippet.encoded = true
57-
58-
return snippet
59-
}

php/rest-api/class-snippets-rest-controller.php

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -396,10 +396,6 @@ protected function prepare_item_for_database( $request, Snippet $item = null ):
396396
}
397397
}
398398

399-
if ( ! empty( $request['encoded'] ) ) {
400-
$item->code = html_entity_decode( $item->code );
401-
}
402-
403399
return $item;
404400
}
405401

0 commit comments

Comments
 (0)