From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on dcvr.yhbt.net X-Spam-Level: X-Spam-ASN: AS4713 221.184.0.0/13 X-Spam-Status: No, score=-2.8 required=3.0 tests=BAYES_00,DKIM_ADSP_CUSTOM_MED, FORGED_GMAIL_RCVD,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED, SPF_PASS shortcircuit=no autolearn=no autolearn_force=no version=3.4.2 Received: from neon.ruby-lang.org (neon.ruby-lang.org [221.186.184.75]) by dcvr.yhbt.net (Postfix) with ESMTP id A546620248 for ; Wed, 13 Mar 2019 16:14:40 +0000 (UTC) Received: from neon.ruby-lang.org (localhost [IPv6:::1]) by neon.ruby-lang.org (Postfix) with ESMTP id 54C51121568; Thu, 14 Mar 2019 01:14:36 +0900 (JST) Received: from o1678948x4.outbound-mail.sendgrid.net (o1678948x4.outbound-mail.sendgrid.net [167.89.48.4]) by neon.ruby-lang.org (Postfix) with ESMTPS id 4337D1215C2 for ; Thu, 14 Mar 2019 01:14:32 +0900 (JST) Received: by filter0048p3las1.sendgrid.net with SMTP id filter0048p3las1-27204-5C892C63-2E 2019-03-13 16:14:27.936615055 +0000 UTC m=+146221.578124287 Received: from herokuapp.com (unknown [3.80.34.250]) by ismtpd0026p1iad2.sendgrid.net (SG) with ESMTP id j9xCmmSOQP-FYstTmsVKfw for ; Wed, 13 Mar 2019 16:14:27.607 +0000 (UTC) Date: Wed, 13 Mar 2019 16:14:28 +0000 (UTC) From: gsamokovarov@gmail.com Message-ID: References: Mime-Version: 1.0 X-Redmine-MailingListIntegration-Message-Ids: 67265 X-Redmine-Project: ruby-trunk X-Redmine-Issue-Id: 15662 X-Redmine-Issue-Author: gsamokovarov X-Redmine-Sender: gsamokovarov X-Mailer: Redmine X-Redmine-Host: bugs.ruby-lang.org X-Redmine-Site: Ruby Issue Tracking System X-Auto-Response-Suppress: All Auto-Submitted: auto-generated X-SG-EID: =?us-ascii?Q?+90nFlVhWwHTWVQNHP0CWxwTaBcDArD07ZooK4Nca3TO+z96YGd92zOhDM1Dd6?= =?us-ascii?Q?GI8bXqQuYvp+1vSRFcqX+u4plzMDFF+nKwmrKMC?= =?us-ascii?Q?kzZ8Qp8e2OE5ev3ldUkGUSe8HWknTdAnkduc75J?= =?us-ascii?Q?RFBMjpmjm1+Za2W6stXAAnrlNsPT4BesU60VCQ6?= =?us-ascii?Q?HaA=2F3ytFbDSl0TAMECx0UX4Lc333feFZNsA=3D=3D?= To: ruby-core@ruby-lang.org X-ML-Name: ruby-core X-Mail-Count: 91813 Subject: [ruby-core:91813] [Ruby trunk Bug#15662] Fix CSV delegation to missing StringIO X-BeenThere: ruby-core@ruby-lang.org X-Mailman-Version: 2.1.15 Precedence: list Reply-To: Ruby developers List-Id: Ruby developers List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: ruby-core-bounces@ruby-lang.org Sender: "ruby-core" Issue #15662 has been updated by gsamokovarov (Genadi Samokovarov). I have opened a PR on GitHub's tracker with the changes: https://github.com/ruby/ruby/pull/2094 ---------------------------------------- Bug #15662: Fix CSV delegation to missing StringIO https://bugs.ruby-lang.org/issues/15662#change-77086 * Author: gsamokovarov (Genadi Samokovarov) * Status: Open * Priority: Normal * Assignee: * Target version: * ruby -v: * Backport: 2.4: UNKNOWN, 2.5: UNKNOWN, 2.6: UNKNOWN ---------------------------------------- If you create a CSV from raw content like: csv = CSV.new("h1,h2") You'll get method missing when calling `csv.path` but still, get `true` when you call `csv.respond_to?(:path)`. This tricks 3rd party libraries like carrierwave which try to call `path` on their input if it responds to it. See https://github.com/carrierwaveuploader/carrierwave/blob/a91ab69fdd8052cdf5a5e48ef8baf40939e441fb/lib/carrierwave/sanitized_file.rb#L109-L123 This stops me from passing CSV objects as StringIO's into carrierwave uploads, for example, but the problem can also be manifested in other 3rd party libraries, as responding to a method and returning a `NoMethodError` when calling it is still an unexpected behavior. I have gone through the CSV delegation scheme and made sure that every method that StringIO doesn't respond to returns a meaningful zero value and does not raise a `NoMethodError` while used through a CSV Instance. -- https://bugs.ruby-lang.org/