-
Notifications
You must be signed in to change notification settings - Fork 700
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Harden url fetcher and don't crash on non-ASCII urls #219
Conversation
@@ -103,6 +102,8 @@ function fetch(url, cb) { | |||
try { | |||
var req = request.get({ | |||
url: url, | |||
maxRedirects: 3, | |||
timeout: 3000, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are these arbitrary? If so, maybe we could go a bit higher, like 5
/10000
, but I don't have an opinion.
I guess we would empirically adjust these values, worst case.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Mostly arbitrary, 3 seconds should be enough to grab page title though. Having too big of a timeout won't be very nice to the user.
Looks good to me, tested working. 👍 I agree with @astorije here that 3 redirects and 3 seconds is a bit low. It's somewhat easy to blow the 3 redirects. Short url + access to invalid area (= redirect to home page of the site) + redirect to regional page, we've reached 3. Some sites can take over 3 seconds to load when crowded (Reddit/imgur are easy examples) too, so 5/10000 sounds reasonable without being abusive. |
Do keep in mind that timeout does not kick in while content is loading On Sun, 27 Mar 2016, 02:23 Max-P, notifications@github.com wrote:
|
So that's a timeout for establishing the connection? I'm fine with that then. |
@xPaw, it makes sense re: title/content, but I often notice that long loading times happen even before the page starts getting in. I'm fine with 5 or 10 seconds then, still wondering if 3 is not a bit too short in some situations. |
It should be, but needs to be looked in more closely to know for sure. On Sun, 27 Mar 2016, 02:31 Max-P, notifications@github.com wrote:
|
I've tweaked it to 5/5000 |
@@ -16,10 +16,9 @@ module.exports = function(irc, network) { | |||
} | |||
|
|||
var links = []; | |||
var split = data.message.split(" "); | |||
var split = data.message.replace(/\x02|\x1D|\x1F|\x16|\x0F|\x03(?:[0-9]{1,2}(?:,[0-9]{1,2})?)?/g, "").split(" "); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For the record/archive purpose, this is the same check as this one, to clean up messages from colors, boldness, ...
👍, thanks for this @xPaw! |
Sending
https://google.com\x0f
would crash some lounge instances due to some obscurities in node.This PR does following: