开发者

open a url feed in codeigniter

What's the best way to open a URL feed in codeigniter? I'm assuming I can't put the URL in a file upload input, so should I use a normal text input and then validate that the URL is not malicious? If so, what validation tests should I perform on the user inputted string? Would checking the file extension be enough or can thi开发者_运维技巧s easily be manipulated?


  1. Use a <input type="text" /> to let users submit URLs
  2. Check that it is a valid URL using regular expressions (and ignore the extension)
    • e.g. preg_match('|^http(s)?://[a-z0-9-]+(.[a-z0-9-]+)*(:[0-9]+)?(/.*)?$|i', $url);
  3. Consider validating the feed with a feed validator (note that many legit feeds may not be "valid")
    • e.g. http://feedvalidator.org/about.html#where
    • e.g. http://www.rss-specifications.com/feed-validators.htm
  4. Try accessing and parsing it
    • http://codeigniter.com/wiki/RSSParser/
    • http://codeigniter.com/wiki/RSSParser-PhilMod/
    • http://www.haughin.com/code/simplepie/
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜