Skip to content

Commit d83a953

Browse files
committed
rss escape fix
1 parent 72800f5 commit d83a953

File tree

3 files changed

+5
-4
lines changed

3 files changed

+5
-4
lines changed

deno.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
"@std/encoding": "jsr:@std/encoding@^1.0.1",
1616
"@std/front-matter": "jsr:@std/front-matter@^1.0.1",
1717
"@std/fs": "jsr:@std/fs@^1.0.1",
18+
"@std/html": "jsr:@std/html@^1.0.1",
1819
"@std/http": "jsr:@std/http@^1.0.0",
1920
"@std/path": "jsr:@std/path@^1.0.2",
2021
"@std/streams": "jsr:@std/streams@^1.0.0",

routes/notes/rss.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import type {DinoHandle} from '@ssr/dinossr';
22
import type {Data} from '@src/types.ts';
33
import {manifest} from '@src/manifest.ts';
44
import {replace, striptags} from '@src/shared.ts';
5+
import {escape, unescape} from '@std/html/entities';
56

67
export const pattern = '.xml';
78

@@ -53,8 +54,7 @@ export const GET: DinoHandle<Data> = () => {
5354
const entries = notes.map((note) => {
5455
let xml = entry;
5556
let description = striptags(note.body);
56-
description = replace(description, '<', '&lt;');
57-
description = replace(description, '>', '&gt;');
57+
description = escape(unescape(description));
5858
const guid = new URL(note.href, meta.url);
5959
xml = replace(xml, `{{description}}`, description);
6060
xml = replace(xml, `{{html}}`, note.body);

routes/rss.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import type {DinoHandle} from '@ssr/dinossr';
22
import type {Data} from '@src/types.ts';
33
import {manifest} from '@src/manifest.ts';
44
import {replace, striptags} from '@src/shared.ts';
5+
import {escape, unescape} from '@std/html/entities';
56

67
export const pattern = '.xml';
78

@@ -54,8 +55,7 @@ export const GET: DinoHandle<Data> = () => {
5455
const pubDate = new Date(bookmark.date!).toUTCString();
5556
const guid = new URL(bookmark.href, meta.url);
5657
let excerpt = striptags(bookmark.excerpt);
57-
excerpt = replace(excerpt, '<', '&lt;');
58-
excerpt = replace(excerpt, '>', '&gt;');
58+
excerpt = escape(unescape(excerpt));
5959
xml = replace(xml, `{{title}}`, bookmark.title);
6060
xml = replace(xml, `{{description}}`, excerpt);
6161
xml = replace(xml, `{{html}}`, bookmark.body);

0 commit comments

Comments
 (0)