[Logilogi-svn] SF.net SVN: logilogi: [318] projects/ogog/trunk/lib/image_parser.rb
Status: Beta
Brought to you by:
wybow
|
From: <wy...@us...> - 2007-05-25 11:57:14
|
Revision: 318
http://logilogi.svn.sourceforge.net/logilogi/?rev=318&view=rev
Author: wybow
Date: 2007-05-25 04:57:07 -0700 (Fri, 25 May 2007)
Log Message:
-----------
Added rescue in case of invalid image-urls
Modified Paths:
--------------
projects/ogog/trunk/lib/image_parser.rb
Modified: projects/ogog/trunk/lib/image_parser.rb
===================================================================
--- projects/ogog/trunk/lib/image_parser.rb 2007-05-25 11:53:10 UTC (rev 317)
+++ projects/ogog/trunk/lib/image_parser.rb 2007-05-25 11:57:07 UTC (rev 318)
@@ -33,18 +33,22 @@
text.gsub!(/\<img(.*?)\>/mi) do |img_tag|
img_tag.tr!("\n",'')
if img_tag =~ /src=\"(.+?)\"/i or img_tag =~ /src=\'(.+?)\'/i
- @image_urls << URI.parse(Regexp.last_match(1)).to_s
- if img_tag =~ /title=\"(.+?)\"/i or img_tag =~ /title=\'(.+?)\'/i
- @titles << Regexp.last_match(1)
- else
- @titles << nil
+ begin
+ @image_urls << URI.parse(Regexp.last_match(1)).to_s
+ if img_tag =~ /title=\"(.+?)\"/i or img_tag =~ /title=\'(.+?)\'/i
+ @titles << Regexp.last_match(1)
+ else
+ @titles << nil
+ end
+ if img_tag =~ /alt=\"(.+?)\"/i or img_tag =~ /alt=\'(.+?)\'/i
+ @alts << Regexp.last_match(1)
+ else
+ @alts << nil
+ end
+ '<br img="O" />'
+ rescue
+ ''
end
- if img_tag =~ /alt=\"(.+?)\"/i or img_tag =~ /alt=\'(.+?)\'/i
- @alts << Regexp.last_match(1)
- else
- @alts << nil
- end
- '<br img="O" />'
else
''
end
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|