[BioRuby-cvs] bioruby/lib/bio reference.rb,1.26,1.27

Naohisa Goto ngoto at dev.open-bio.org
Mon Jun 2 09:33:50 UTC 2008


Update of /home/repository/bioruby/bioruby/lib/bio
In directory dev.open-bio.org:/tmp/cvs-serv25887

Modified Files:
	reference.rb 
Log Message:
reverted to 1.24, because of potential security problem about "eval" in
bibtex method.


Index: reference.rb
===================================================================
RCS file: /home/repository/bioruby/bioruby/lib/bio/reference.rb,v
retrieving revision 1.26
retrieving revision 1.27
diff -C2 -d -r1.26 -r1.27
*** reference.rb	31 May 2008 09:36:55 -0000	1.26
--- reference.rb	2 Jun 2008 09:33:48 -0000	1.27
***************
*** 71,74 ****
--- 71,77 ----
      attr_reader :abstract
  
+     # An URL String.
+     attr_reader :url
+ 
      # MeSH terms in an Array.
      attr_reader :mesh
***************
*** 77,83 ****
      attr_reader :affiliations
  
-     # An URL String.
-     attr_reader :url
- 
      # Create a new Bio::Reference object from a Hash of values. 
      # Data is extracted from the values for keys:
--- 80,83 ----
***************
*** 232,236 ****
        lines << "%P #{@pages}" unless @pages.empty?
        lines << "%M #{@pubmed}" unless @pubmed.to_s.empty?
!       lines << "%U #{url}" unless url.empty?
        lines << "%X #{@abstract}" unless @abstract.empty?
        @mesh.each do |term|
--- 232,241 ----
        lines << "%P #{@pages}" unless @pages.empty?
        lines << "%M #{@pubmed}" unless @pubmed.to_s.empty?
!       if @pubmed
!         cgi = "http://www.ncbi.nlm.nih.gov/entrez/query.fcgi"
!         opts = "cmd=Retrieve&db=PubMed&dopt=Citation&list_uids"
!         @url = "#{cgi}?#{opts}=#{@pubmed}"
!       end
!       lines << "%U #{@url}" unless @url.empty?
        lines << "%X #{@abstract}" unless @abstract.empty?
        @mesh.each do |term|
***************
*** 294,321 ****
      # *Arguments*:
      # * (optional) _section_: BiBTeX section as String
-     # * (optional) _keywords_: Array of additional keywords, e.g. ['abstract']
      # *Returns*:: String
!     def bibtex(section = nil, add_keywords = [])
        section = "article" unless section
        authors = authors_join(' and ', ' and ')
        pages   = @pages.sub('-', '--')
!       keywords = "author title journal year volume number pages url".split(/ /)
!       bib = "@#{section}{PMID:#{@pubmed},\n"
!       (keywords+add_keywords).each do | kw |
!         if kw == 'author'
!           ref = authors
!         elsif kw == 'title'
!           # strip final dot from title
!           ref = @title.sub(/\.$/,'')
!         elsif kw == 'number'
!           ref = @issue
!         elsif kw == 'url'
!           ref = url
!         else
!           ref = eval('@'+kw)
!         end
!         bib += "  #{kw.ljust(12)} = {#{ref}},\n" if ref != ''
!       end
!       bib+"}\n"
      end
  
--- 299,318 ----
      # *Arguments*:
      # * (optional) _section_: BiBTeX section as String
      # *Returns*:: String
!     def bibtex(section = nil)
        section = "article" unless section
        authors = authors_join(' and ', ' and ')
        pages   = @pages.sub('-', '--')
!       return <<-"END".gsub(/\t/, '')
!         @#{section}{PMID:#{@pubmed},
!           author  = {#{authors}},
!           title   = {#{@title}},
!           journal = {#{@journal}},
!           year    = {#{@year}},
!           volume  = {#{@volume}},
!           number  = {#{@issue}},
!           pages   = {#{pages}},
!         }
!       END
      end
  
***************
*** 503,518 ****
      end
  
-     # Returns a valid URL for pubmed records
-     #
-     # *Returns*:: String
-     def url
-       return @url if @url and @url != ''
-       if @pubmed != ''
-         cgi = "http://www.ncbi.nlm.nih.gov/entrez/query.fcgi"
-         opts = "cmd=Retrieve&db=PubMed&dopt=Citation&list_uids"
-         return "#{cgi}?#{opts}=#{@pubmed}"
-       end
-       ''
-     end
  
      private
--- 500,503 ----
***************
*** 542,546 ****
      end
  
- 
    end
  
--- 527,530 ----




More information about the bioruby-cvs mailing list