Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Use Time.parse_safely in Feed.last_modified_from_header. #129

Merged
merged 1 commit into from

2 participants

@benubois

This helps prevent parse failures when there is a problem with the last modified header. For example if the Last-Modified header is empty like on http://feeds.kottke.org/main.

Looks like most of feedzirra already uses parse_safely for Time parsing.

curl -v http://feeds.kottke.org/main
* About to connect() to feeds.kottke.org port 80 (#0)
*   Trying 216.243.171.10...
* connected
* Connected to feeds.kottke.org (216.243.171.10) port 80 (#0)
> GET /main HTTP/1.1
> User-Agent: curl/7.24.0 (x86_64-apple-darwin12.0) libcurl/7.24.0 OpenSSL/0.9.8r zlib/1.2.5
> Host: feeds.kottke.org
> Accept: */*
> 
< HTTP/1.1 200 OK
< Date: Mon, 19 Nov 2012 04:33:38 GMT
< Server: Apache
< X-Powered-By: PHP/5.3.2-1ubuntu4.18
< Last-Modified: 
< Transfer-Encoding: chunked
< Content-Type: text/xml
< Vary: Accept-Encoding, User-Agent
< 
@benubois benubois Use Time.parse_safely in Feed.last_modified_from_header.
This helps prevent parse failures when there is a problem with the last
modified header. For example if the Last-Modified header is empty like on
http://feeds.kottke.org/main.
0391ed8
@ezkl ezkl merged commit 1715124 into feedjira:master
@ezkl

Thanks, @benubois!

@ezkl ezkl referenced this pull request from a commit
@ezkl ezkl Add #129 to changelog ec2c8d2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Nov 19, 2012
  1. @benubois

    Use Time.parse_safely in Feed.last_modified_from_header.

    benubois authored
    This helps prevent parse failures when there is a problem with the last
    modified header. For example if the Last-Modified header is empty like on
    http://feeds.kottke.org/main.
This page is out of date. Refresh to see the latest.
Showing with 1 addition and 1 deletion.
  1. +1 −1  lib/feedzirra/feed.rb
View
2  lib/feedzirra/feed.rb
@@ -376,7 +376,7 @@ def self.etag_from_header(header)
# A Time object of the last modified date or nil if it cannot be found in the headers.
def self.last_modified_from_header(header)
header =~ /.*Last-Modified:\s(.*)\r/
- Time.parse($1) if $1
+ Time.parse_safely($1) if $1
end
end
end
Something went wrong with that request. Please try again.