Commit 158fbfe
committed
feat: implement Phase 3 - JSON Feed parser, utilities, and DRY refactoring
Phase 3 Implementation:
- Add JSON Feed 1.0/1.1 parser with full spec support
- Implement extended date parsing (20+ formats including RFC 2822, RFC 3339, ISO 8601)
- Add HTML sanitization with ammonia (XSS protection, safe tags whitelist)
- Add encoding detection with BOM support (UTF-8, UTF-16 LE/BE, UTF-32)
- Add encoding conversion via encoding_rs
Code Deduplication (ParseFrom trait with GAT):
- Add generic ParseFrom<Source> trait for unified parsing interface
- Implement ParseFrom<&Value> for Person and Enclosure (JSON parsing)
- Add builder methods: Link::alternate(), Link::self_link(), Link::enclosure()
- Add builder methods: TextConstruct::text(), TextConstruct::html()
- Add builder methods: Content::html(), Content::plain(), Tag::new()
- Unify author parsing logic with parse_authors() helper
Security:
- Enforce parser limits (max_entries, max_text_length, max_nesting_depth)
- Proper BOM detection order (UTF-32 before UTF-16)
- HTML sanitization prevents XSS attacks
Tests:
- 164 tests passing (154 unit + 10 integration)
- JSON Feed parsing tests with fixtures
- Encoding detection and conversion tests
- HTML sanitization security tests1 parent 43a0c66 commit 158fbfe
File tree
17 files changed
+1421
-38
lines changed- crates/feedparser-rs-core
- src
- parser
- types
- util
- tests
- tests/fixtures/json
17 files changed
+1421
-38
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
42 | 42 | | |
43 | 43 | | |
44 | 44 | | |
45 | | - | |
46 | | - | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
47 | 57 | | |
48 | 58 | | |
49 | 59 | | |
50 | 60 | | |
51 | 61 | | |
52 | | - | |
53 | | - | |
| 62 | + | |
| 63 | + | |
54 | 64 | | |
55 | 65 | | |
56 | 66 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
32 | 32 | | |
33 | 33 | | |
34 | 34 | | |
35 | | - | |
36 | | - | |
37 | | - | |
| 35 | + | |
38 | 36 | | |
39 | 37 | | |
40 | 38 | | |
| |||
47 | 45 | | |
48 | 46 | | |
49 | 47 | | |
| 48 | + | |
50 | 49 | | |
51 | 50 | | |
52 | 51 | | |
| |||
100 | 99 | | |
101 | 100 | | |
102 | 101 | | |
103 | | - | |
| 102 | + | |
104 | 103 | | |
105 | 104 | | |
106 | 105 | | |
| |||
240 | 239 | | |
241 | 240 | | |
242 | 241 | | |
243 | | - | |
| 242 | + | |
244 | 243 | | |
245 | 244 | | |
246 | 245 | | |
| |||
494 | 493 | | |
495 | 494 | | |
496 | 495 | | |
497 | | - | |
| 496 | + | |
498 | 497 | | |
499 | 498 | | |
500 | 499 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
21 | 21 | | |
22 | 22 | | |
23 | 23 | | |
| 24 | + | |
| 25 | + | |
24 | 26 | | |
25 | 27 | | |
26 | 28 | | |
| |||
88 | 90 | | |
89 | 91 | | |
90 | 92 | | |
| 93 | + | |
91 | 94 | | |
| 95 | + | |
92 | 96 | | |
93 | 97 | | |
94 | 98 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
97 | 97 | | |
98 | 98 | | |
99 | 99 | | |
100 | | - | |
| 100 | + | |
101 | 101 | | |
102 | 102 | | |
103 | 103 | | |
| |||
0 commit comments