SReject commented on a Page, Image Viewer / Opener  -  Jan 20, 2013

A few things I've spotted real quick
1: why is the 7 escaped in your regex @ gopher)\72
2: HTTPS, FTP and gopher, afaik, is a competely different protocol from http, meaning the GET ... Host: headers are invalidly used.
3: Instead of coding the 'redirect' for puu.sh, why not just have your sockets follow redirects?

illhawkthat  -  Jan 20, 2013

Thanks for the feedback @SReject
1 and 2 - I'm not sure because I didn't make the regex string. (thanks to Wiz126 #msl swiftirc for it) - I will look into changing it to better fit this script in the future. (Also I don't really see people link to FTP or Gopher images so they seem useless haha)

  1. it's not a 301 redirect. the puu.sh links ARE direct image links but they don't have a file extension. I added a comment to show this.

I made some edits to the code above.

Conscious  -  Jan 21, 2013

\72 is octal for :

SReject  -  Jan 21, 2013

I didn't really test it, but i think this would be a far better regex:

/(?:http:\/\/)?(?:www\.)?(|(\S+\.(?:jpe?g|gif|png))|(puu\.sh\/\w+))/Sig

@Conscious after I commented, I remember

illhawkthat  -  Jan 21, 2013

@SReject It works for https links. What are you doing? I also thinkit would work for FTP links. I don't know shit about gopher.
Appreciate it though. Can you add imgur in there? (I'm shit with regex).

SReject  -  Jan 21, 2013

@illhawkthat It doesn't work for https or ftp links. It is basically converting the URL to a HTTP link. Some/Most servers support an HTTP fall back for HTTPS links.

illhawkthat  -  Jan 21, 2013

I know. That's why I strip the HTTPS - for direct image links I think the server almost always accepts HTTP

    set %getpic $remove($1,http://,https://)
SReject  -  Jan 21, 2013

Sorry if I keep coming off sounding arrogant, it's not my intention. If you wanted true HTTPS(not sure, but I think FTP aswell) support, you could use one of these inplace of your sockets:

Call back style downloading of a file:
http://www.hawkee.com/snippet/9318/

Semi-blocking downloading of a file:
http://www.hawkee.com/snippet/8993/

illhawkthat  -  Jan 21, 2013

No not at all arrogant! I appreciate the comments!! I don't really feel like replacing this though. I made it about a year ago just because it was annyoing me people kept linking images.

But for now it works on all the images I have tried. Thanks though!!

Conscious  -  Jan 21, 2013

SSL sockets could be made using sockopen -e

And @SReject is right, HTTP protocol does not work with FTP, lol

illhawkthat  -  Jan 21, 2013

Thanks @Conscious I'll put up a new regex string within the week when I can find someone to make one for me haha. I appreciate all the feedback!

Sign in to comment

Are you sure you want to unfollow this person?
Are you sure you want to delete this?
Click "Unsubscribe" to stop receiving notices pertaining to this post.
Click "Subscribe" to resume notices pertaining to this post.