Project

General

Profile

Bug #15933 ยป ruby-changes.patch

gareth (Gareth Adams), 06/19/2019 11:42 AM

View differences:

lib/open-uri.rb
543 543
    # It can be used to guess charset.
544 544
    #
545 545
    # If charset parameter and block is not given,
546
    # nil is returned except text type in HTTP.
546
    # nil is returned except text type.
547 547
    # In that case, "iso-8859-1" is returned as defined by RFC2616 3.7.1.
548 548
    def charset
549 549
      type, *parameters = content_type_parse
......
551 551
        pair.last.downcase
552 552
      elsif block_given?
553 553
        yield
554
      elsif type && %r{\Atext/} =~ type &&
555
            @base_uri && /\Ahttp\z/i =~ @base_uri.scheme
554
      elsif type && %r{\Atext/} =~ type
556 555
        "iso-8859-1" # RFC2616 3.7.1
557 556
      else
558 557
        nil
559
- 
lib/open-uri.rb
544 544
    #
545 545
    # If charset parameter and block is not given,
546 546
    # nil is returned except text type.
547
    # In that case, "iso-8859-1" is returned as defined by RFC2616 3.7.1.
547
    # In that case, "utf-8" is returned as defined by RFC6838 4.2.1
548 548
    def charset
549 549
      type, *parameters = content_type_parse
550 550
      if pair = parameters.assoc('charset')
......
552 552
      elsif block_given?
553 553
        yield
554 554
      elsif type && %r{\Atext/} =~ type
555
        "iso-8859-1" # RFC2616 3.7.1
555
        "utf-8" # RFC6838 4.2.1
556 556
      else
557 557
        nil
558 558
      end