Skip to content

Commit

Permalink
rss escape fix
Browse files Browse the repository at this point in the history
  • Loading branch information
dbushell committed Aug 21, 2024
1 parent 72800f5 commit d83a953
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 4 deletions.
1 change: 1 addition & 0 deletions deno.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
"@std/encoding": "jsr:@std/encoding@^1.0.1",
"@std/front-matter": "jsr:@std/front-matter@^1.0.1",
"@std/fs": "jsr:@std/fs@^1.0.1",
"@std/html": "jsr:@std/html@^1.0.1",
"@std/http": "jsr:@std/http@^1.0.0",
"@std/path": "jsr:@std/path@^1.0.2",
"@std/streams": "jsr:@std/streams@^1.0.0",
Expand Down
4 changes: 2 additions & 2 deletions routes/notes/rss.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import type {DinoHandle} from '@ssr/dinossr';
import type {Data} from '@src/types.ts';
import {manifest} from '@src/manifest.ts';
import {replace, striptags} from '@src/shared.ts';
import {escape, unescape} from '@std/html/entities';

export const pattern = '.xml';

Expand Down Expand Up @@ -53,8 +54,7 @@ export const GET: DinoHandle<Data> = () => {
const entries = notes.map((note) => {
let xml = entry;
let description = striptags(note.body);
description = replace(description, '<', '&lt;');
description = replace(description, '>', '&gt;');
description = escape(unescape(description));
const guid = new URL(note.href, meta.url);
xml = replace(xml, `{{description}}`, description);
xml = replace(xml, `{{html}}`, note.body);
Expand Down
4 changes: 2 additions & 2 deletions routes/rss.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import type {DinoHandle} from '@ssr/dinossr';
import type {Data} from '@src/types.ts';
import {manifest} from '@src/manifest.ts';
import {replace, striptags} from '@src/shared.ts';
import {escape, unescape} from '@std/html/entities';

export const pattern = '.xml';

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

0 comments on commit d83a953

Please sign in to comment.