Skip to content

Commit

Permalink
Fix URI errors
Browse files Browse the repository at this point in the history
  • Loading branch information
dar5hak committed Sep 29, 2024
1 parent acfdd06 commit 4c8ad94
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 9 deletions.
8 changes: 4 additions & 4 deletions src/ContentGrabber/grabber.vala
Original file line number Diff line number Diff line change
Expand Up @@ -105,9 +105,9 @@ public class FeedReader.Grabber : GLib.Object {
{
Logger.debug("Grabber: process article: " + m_articleURL);

var uri = new Soup.URI(m_articleURL);
if(uri == null)
{
try {
var uri = GLib.Uri.parse(m_articleURL, GLib.UriFlags.NONE);
} catch (GLib.UriError e) {
Logger.error("No valid article-url?!?");
return false;
}
Expand Down Expand Up @@ -229,7 +229,7 @@ public class FeedReader.Grabber : GLib.Object {
if(msg.status_code == Soup.Status.MOVED_TEMPORARILY
|| msg.status_code == Soup.Status.MOVED_PERMANENTLY)
{
m_articleURL = msg.uri.to_string(false);
m_articleURL = msg.uri.to_string();
m_article.setURL(m_articleURL);
Logger.debug("Grabber: new url is: " + m_articleURL);
}
Expand Down
8 changes: 7 additions & 1 deletion src/FavIcon.vala
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,13 @@ public class FeedReader.FavIcon : GLib.Object
}

// try domainname/favicon.ico
var uri = new Soup.URI(m_feed.getURL());
GLib.Uri uri;
try {
uri = GLib.Uri.parse(m_feed.getURL(), GLib.UriFlags.NONE);
} catch (GLib.UriError e) {
Logger.error(@"Fetching favicon failed: can't parse url $(m_feed.getURL())! Seems to be not valid.");
}

string? siteURL = null;
if(uri != null)
{
Expand Down
8 changes: 4 additions & 4 deletions src/Utils.vala
Original file line number Diff line number Diff line change
Expand Up @@ -263,10 +263,10 @@ public class FeedReader.Utils : GLib.Object {
public static bool ping(string link)
{
Logger.debug("Ping: " + link);
var uri = new Soup.URI(link);

if(uri == null)
{
GLib.Uri uri;
try {
uri = GLib.Uri.parse(link, GLib.UriFlags.NONE);
} catch (GLib.UriError e) {
Logger.error(@"Ping failed: can't parse url $link! Seems to be not valid.");
return false;
}
Expand Down

0 comments on commit 4c8ad94

Please sign in to comment.