Package: newsbeuter / 2.9-5+deb9u2

20-prevent-http-header-reset.patch Patch series | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
Origin: upstream, https://github.com/akrennmair/newsbeuter/commit/fccad71a21fadbfc0da4bfd1527de56ca03f67e5

--- a/include/feedhq_api.h
+++ b/include/feedhq_api.h
@@ -13,7 +13,7 @@
 		virtual ~feedhq_api();
 		virtual bool authenticate();
 		virtual std::vector<tagged_feedurl> get_subscribed_urls();
-		virtual void configure_handle(CURL * handle);
+		virtual void configure_handle(curl_slist** custom_headers);
 		virtual bool mark_all_read(const std::string& feedurl);
 		virtual bool mark_article_read(const std::string& guid, bool read);
 		virtual bool update_article_flags(const std::string& oldflags, const std::string& newflags, const std::string& guid);
@@ -27,6 +27,7 @@
 		bool share_article(const std::string& guid, bool share);
 		bool mark_article_read_with_token(const std::string& guid, bool read, const std::string& token);
 		std::string auth;
+		std::string auth_header;
 };
 
 class feedhq_urlreader : public urlreader {
--- a/include/newsblur_api.h
+++ b/include/newsblur_api.h
@@ -18,7 +18,7 @@
 		virtual ~newsblur_api();
 		virtual bool authenticate();
 		virtual std::vector<tagged_feedurl> get_subscribed_urls();
-		virtual void configure_handle(CURL * handle);
+		virtual void configure_handle(curl_slist** custom_headers);
 		virtual bool mark_all_read(const std::string& feedurl);
 		virtual bool mark_article_read(const std::string& guid, bool read);
 		virtual bool update_article_flags(const std::string& oldflags, const std::string& newflags, const std::string& guid);
--- a/include/oldreader_api.h
+++ b/include/oldreader_api.h
@@ -13,7 +13,7 @@
 		virtual ~oldreader_api();
 		virtual bool authenticate();
 		virtual std::vector<tagged_feedurl> get_subscribed_urls();
-		virtual void configure_handle(CURL * handle);
+		virtual void configure_handle(curl_slist** custom_headers);
 		virtual bool mark_all_read(const std::string& feedurl);
 		virtual bool mark_article_read(const std::string& guid, bool read);
 		virtual bool update_article_flags(const std::string& oldflags, const std::string& newflags, const std::string& guid);
@@ -27,6 +27,7 @@
 		bool share_article(const std::string& guid, bool share);
 		bool mark_article_read_with_token(const std::string& guid, bool read, const std::string& token);
 		std::string auth;
+		std::string auth_header;
 };
 
 class oldreader_urlreader : public urlreader {
--- a/include/remote_api.h
+++ b/include/remote_api.h
@@ -17,7 +17,7 @@
 		virtual ~remote_api() { }
 		virtual bool authenticate() = 0;
 		virtual std::vector<tagged_feedurl> get_subscribed_urls() = 0;
-		virtual void configure_handle(CURL * handle) = 0;
+		virtual void configure_handle(curl_slist** custom_headers) = 0;
 		virtual bool mark_all_read(const std::string& feedurl) = 0;
 		virtual bool mark_article_read(const std::string& guid, bool read) = 0;
 		virtual bool update_article_flags(const std::string& oldflags, const std::string& newflags, const std::string& guid) = 0;
--- a/include/ttrss_api.h
+++ b/include/ttrss_api.h
@@ -16,7 +16,7 @@
 		virtual struct json_object * run_op(const std::string& op, const std::map<std::string, std::string>& args,
 		                                    bool try_login = true);
 		virtual std::vector<tagged_feedurl> get_subscribed_urls();
-		virtual void configure_handle(CURL * handle);
+		virtual void configure_handle(curl_slist** custom_headers);
 		virtual bool mark_all_read(const std::string& feedurl);
 		virtual bool mark_article_read(const std::string& guid, bool read);
 		virtual bool update_article_flags(const std::string& oldflags, const std::string& newflags, const std::string& guid);
--- a/rss/parser.cpp
+++ b/rss/parser.cpp
@@ -72,6 +72,7 @@
 feed parser::parse_url(const std::string& url, time_t lastmodified, const std::string& etag, newsbeuter::remote_api * api, const std::string& cookie_cache, CURL *ehandle) {
 	std::string buf;
 	CURLcode ret;
+	curl_slist* custom_headers {};
 
 	CURL * easyhandle = ehandle;
 	if (!easyhandle) {
@@ -84,8 +85,9 @@
 	if (ua) {
 		curl_easy_setopt(easyhandle, CURLOPT_USERAGENT, ua);
 	}
+
 	if (api) {
-		api->configure_handle(easyhandle);
+		api->configure_handle(&custom_headers);
 	}
 	curl_easy_setopt(easyhandle, CURLOPT_URL, url.c_str());
 	curl_easy_setopt(easyhandle, CURLOPT_SSL_VERIFYPEER, verify_ssl);
@@ -122,9 +124,13 @@
 		curl_easy_setopt(easyhandle, CURLOPT_TIMEVALUE, lastmodified);
 	}
 
-	curl_slist * custom_headers = NULL;
 	if (etag.length() > 0) {
-		custom_headers = curl_slist_append(custom_headers, utils::strprintf("If-None-Match: %s", etag.c_str()).c_str());
+		custom_headers = curl_slist_append(
+				custom_headers,
+				utils::strprintf("If-None-Match: %s", etag.c_str()).c_str());
+	}
+
+	if(custom_headers) {
 		curl_easy_setopt(easyhandle, CURLOPT_HTTPHEADER, custom_headers);
 	}
 
@@ -147,6 +153,8 @@
 		LOG(LOG_USERERROR, _("Error: trying to download feed `%s' returned HTTP status code %ld."), url.c_str(), status);
 	}
 
+	curl_easy_reset(easyhandle);
+
 	if (!ehandle)
 		curl_easy_cleanup(easyhandle);
 
--- a/src/feedhq_api.cpp
+++ b/src/feedhq_api.cpp
@@ -118,7 +118,9 @@
 
 	CURL * handle = curl_easy_init();
 	std::string result;
-	configure_handle(handle);
+	curl_slist* custom_headers {};
+	configure_handle(&custom_headers);
+	curl_easy_setopt(handle, CURLOPT_HTTPHEADER, custom_headers);
 
 	utils::set_common_curl_options(handle, cfg);
 	curl_easy_setopt(handle, CURLOPT_WRITEFUNCTION, my_write_data);
@@ -175,12 +177,14 @@
 	return urls;
 }
 
-void feedhq_api::configure_handle(CURL * handle) {
-	struct curl_slist *chunk = NULL;
-	std::string header = utils::strprintf("Authorization: GoogleLogin auth=%s", auth.c_str());
-	LOG(LOG_DEBUG, "feedhq_api::configure_handle header = %s", header.c_str());
-	chunk = curl_slist_append(chunk, header.c_str());
-	curl_easy_setopt(handle, CURLOPT_HTTPHEADER, chunk);
+void feedhq_api::configure_handle(curl_slist** custom_headers) {
+	if(auth_header.empty()) {
+		auth_header = utils::strprintf(
+				"Authorization: GoogleLogin auth=%s", auth.c_str());
+	}
+	LOG(LOG_DEBUG, "feedhq_api::configure_handle header = %s",
+			auth_header.c_str());
+	*custom_headers = curl_slist_append(*custom_headers, auth_header.c_str());
 }
 
 bool feedhq_api::mark_all_read(const std::string& feedurl) {
@@ -240,9 +244,11 @@
 std::string feedhq_api::get_new_token() {
 	CURL * handle = curl_easy_init();
 	std::string result;
+	curl_slist* custom_headers {};
 
 	utils::set_common_curl_options(handle, cfg);
-	configure_handle(handle);
+	configure_handle(&custom_headers);
+	curl_easy_setopt(handle, CURLOPT_HTTPHEADER, custom_headers);
 	curl_easy_setopt(handle, CURLOPT_WRITEFUNCTION, my_write_data);
 	curl_easy_setopt(handle, CURLOPT_WRITEDATA, &result);
 	curl_easy_setopt(handle, CURLOPT_URL, FEEDHQ_API_TOKEN_URL);
@@ -310,10 +316,12 @@
 
 std::string feedhq_api::post_content(const std::string& url, const std::string& postdata) {
 	std::string result;
+	curl_slist* custom_headers {};
 
 	CURL * handle = curl_easy_init();
 	utils::set_common_curl_options(handle, cfg);
-	configure_handle(handle);
+	configure_handle(&custom_headers);
+	curl_easy_setopt(handle, CURLOPT_HTTPHEADER, custom_headers);
 	curl_easy_setopt(handle, CURLOPT_WRITEFUNCTION, my_write_data);
 	curl_easy_setopt(handle, CURLOPT_WRITEDATA, &result);
 	curl_easy_setopt(handle, CURLOPT_POSTFIELDS, postdata.c_str());
--- a/src/newsblur_api.cpp
+++ b/src/newsblur_api.cpp
@@ -69,7 +69,7 @@
 	return result;
 }
 
-void newsblur_api::configure_handle(CURL * /*handle*/) {
+void newsblur_api::configure_handle(curl_slist** /* custom_headers */) {
 	// nothing required
 }
 
--- a/src/oldreader_api.cpp
+++ b/src/oldreader_api.cpp
@@ -117,10 +117,12 @@
 
 std::vector<tagged_feedurl> oldreader_api::get_subscribed_urls() {
 	std::vector<tagged_feedurl> urls;
+	curl_slist* custom_headers {};
 
 	CURL * handle = curl_easy_init();
 	std::string result;
-	configure_handle(handle);
+	configure_handle(&custom_headers);
+	curl_easy_setopt(handle, CURLOPT_HTTPHEADER, custom_headers);
 
 	utils::set_common_curl_options(handle, cfg);
 	curl_easy_setopt(handle, CURLOPT_WRITEFUNCTION, my_write_data);
@@ -158,9 +160,19 @@
 		json_object_object_get_ex(sub, "title", &node);
 		const char * title = json_object_get_string(node);
 
-		tags.push_back(std::string("~") + title);
-
-		urls.push_back(tagged_feedurl(utils::strprintf("%s%s?n=%u", OLDREADER_FEED_PREFIX, id, cfg->get_configvalue_as_int("oldreader-min-items")), tags));
+		// Ignore URLs where ID start with given prefix - those never load,
+		// always returning 404 and annoying people
+		const char* prefix = "tor/sponsored/";
+		if(strncmp(id, prefix, strlen(prefix)) != 0) {
+			tags.push_back(std::string("~") + title);
+
+			auto url = utils::strprintf(
+				"%s%s?n=%u",
+				OLDREADER_FEED_PREFIX,
+				id,
+				cfg->get_configvalue_as_int("oldreader-min-items"));
+			urls.push_back(tagged_feedurl(url, tags));
+		}
 	}
 
 	json_object_put(reply);
@@ -168,12 +180,12 @@
 	return urls;
 }
 
-void oldreader_api::configure_handle(CURL * handle) {
-	struct curl_slist *chunk = NULL;
-	std::string header = utils::strprintf("Authorization: GoogleLogin auth=%s", auth.c_str());
-	LOG(LOG_DEBUG, "oldreader_api::configure_handle header = %s", header.c_str());
-	chunk = curl_slist_append(chunk, header.c_str());
-	curl_easy_setopt(handle, CURLOPT_HTTPHEADER, chunk);
+void oldreader_api::configure_handle(curl_slist** custom_headers) {
+	if(auth_header.empty()) {
+		auth_header = utils::strprintf("Authorization: GoogleLogin auth=%s", auth.c_str());
+	}
+	LOG(LOG_DEBUG, "oldreader_api::configure_handle header = %s", auth_header.c_str());
+	*custom_headers = curl_slist_append(*custom_headers, auth_header.c_str());
 }
 
 bool oldreader_api::mark_all_read(const std::string& feedurl) {
@@ -232,9 +244,11 @@
 std::string oldreader_api::get_new_token() {
 	CURL * handle = curl_easy_init();
 	std::string result;
+	curl_slist* custom_headers {};
 
 	utils::set_common_curl_options(handle, cfg);
-	configure_handle(handle);
+	configure_handle(&custom_headers);
+	curl_easy_setopt(handle, CURLOPT_HTTPHEADER, custom_headers);
 	curl_easy_setopt(handle, CURLOPT_WRITEFUNCTION, my_write_data);
 	curl_easy_setopt(handle, CURLOPT_WRITEDATA, &result);
 	curl_easy_setopt(handle, CURLOPT_URL, OLDREADER_API_TOKEN_URL);
@@ -302,10 +316,12 @@
 
 std::string oldreader_api::post_content(const std::string& url, const std::string& postdata) {
 	std::string result;
+	curl_slist* custom_headers {};
 
 	CURL * handle = curl_easy_init();
 	utils::set_common_curl_options(handle, cfg);
-	configure_handle(handle);
+	configure_handle(&custom_headers);
+	curl_easy_setopt(handle, CURLOPT_HTTPHEADER, custom_headers);
 	curl_easy_setopt(handle, CURLOPT_WRITEFUNCTION, my_write_data);
 	curl_easy_setopt(handle, CURLOPT_WRITEDATA, &result);
 	curl_easy_setopt(handle, CURLOPT_POSTFIELDS, postdata.c_str());
--- a/src/ttrss_api.cpp
+++ b/src/ttrss_api.cpp
@@ -181,7 +181,7 @@
 	return feeds;
 }
 
-void ttrss_api::configure_handle(CURL * /*handle*/) {
+void ttrss_api::configure_handle(curl_slist** /* custom_headers */) {
 	// nothing required
 }