rssfeed 0.4.1__tar.gz → 0.4.2__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {rssfeed-0.4.1 → rssfeed-0.4.2}/PKG-INFO +4 -3
- {rssfeed-0.4.1 → rssfeed-0.4.2}/README.md +3 -2
- {rssfeed-0.4.1 → rssfeed-0.4.2}/pyproject.toml +1 -1
- {rssfeed-0.4.1 → rssfeed-0.4.2}/rssfeed/lib.py +5 -5
- {rssfeed-0.4.1 → rssfeed-0.4.2}/LICENSE +0 -0
- {rssfeed-0.4.1 → rssfeed-0.4.2}/rssfeed/__init__.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: rssfeed
|
|
3
|
-
Version: 0.4.
|
|
3
|
+
Version: 0.4.2
|
|
4
4
|
Summary: A simple rss/atom feed parser
|
|
5
5
|
Keywords: rssfeed,rss,feed,atom,opml
|
|
6
6
|
Author: p7e4
|
|
@@ -67,7 +67,7 @@ rssfeed.parse(text)
|
|
|
67
67
|
}
|
|
68
68
|
```
|
|
69
69
|
|
|
70
|
-
> rssfeed **does not** escape HTML
|
|
70
|
+
> rssfeed **does not** escape HTML tags, which means you had to sanitization content otherwise it may lead to [Cross-site scripting](https://developer.mozilla.org/en-US/docs/Glossary/Cross-site_scripting) attacks, a recommended choice is [nh3](https://github.com/messense/nh3).
|
|
71
71
|
|
|
72
72
|
|
|
73
73
|
### opml parse
|
|
@@ -115,5 +115,6 @@ rssfeed.opmlParse(opml)
|
|
|
115
115
|
}
|
|
116
116
|
```
|
|
117
117
|
|
|
118
|
-
|
|
118
|
+
|
|
119
|
+
|
|
119
120
|
|
|
@@ -49,7 +49,7 @@ rssfeed.parse(text)
|
|
|
49
49
|
}
|
|
50
50
|
```
|
|
51
51
|
|
|
52
|
-
> rssfeed **does not** escape HTML
|
|
52
|
+
> rssfeed **does not** escape HTML tags, which means you had to sanitization content otherwise it may lead to [Cross-site scripting](https://developer.mozilla.org/en-US/docs/Glossary/Cross-site_scripting) attacks, a recommended choice is [nh3](https://github.com/messense/nh3).
|
|
53
53
|
|
|
54
54
|
|
|
55
55
|
### opml parse
|
|
@@ -97,5 +97,6 @@ rssfeed.opmlParse(opml)
|
|
|
97
97
|
}
|
|
98
98
|
```
|
|
99
99
|
|
|
100
|
-
|
|
100
|
+
|
|
101
|
+
|
|
101
102
|
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
from dateutil.parser import parse as timeParse
|
|
2
2
|
from xml.etree import ElementTree
|
|
3
3
|
|
|
4
|
-
__version__ = "0.4.
|
|
4
|
+
__version__ = "0.4.2"
|
|
5
5
|
|
|
6
6
|
class ParseError(Exception):
|
|
7
7
|
pass
|
|
@@ -17,7 +17,8 @@ def _parse(data):
|
|
|
17
17
|
raise ParseError("xml parse fail") from e
|
|
18
18
|
return parser
|
|
19
19
|
|
|
20
|
-
def parse(data):
|
|
20
|
+
def parse(data, url=None):
|
|
21
|
+
if url: url = url[:8] + url[8:].rsplit("/")[0]
|
|
21
22
|
items = list()
|
|
22
23
|
for event, elem in _parse(data).read_events():
|
|
23
24
|
tag = elem.tag.split("}", 1)[1] if elem.tag.startswith("{") else elem.tag
|
|
@@ -44,14 +45,13 @@ def parse(data):
|
|
|
44
45
|
i["timestamp"] = int(timeParse(text).timestamp())
|
|
45
46
|
except Exception as e:
|
|
46
47
|
raise ParseError("time parse fail") from e
|
|
47
|
-
# if len(items) and items[0]["timestamp"] < i["timestamp"]:
|
|
48
|
-
# items[0]["timestamp"] = i["timestamp"]
|
|
49
48
|
case "link":
|
|
50
49
|
i["url"] = text or elem.get("href")
|
|
50
|
+
if url and not i["url"].startswith("http"):
|
|
51
|
+
i["url"] = f"{url}/{i["url"].lstrip("/")}"
|
|
51
52
|
case "title" | "author":
|
|
52
53
|
i[tag] = text
|
|
53
54
|
|
|
54
|
-
|
|
55
55
|
if not items:
|
|
56
56
|
raise ParseError("not valid result")
|
|
57
57
|
|
|
File without changes
|
|
File without changes
|