ruby-core@ruby-lang.org archive (unofficial mirror)
 help / color / mirror / Atom feed
* [ruby-core:72426] [Ruby trunk - Bug #11858] [Open] CGI.escapeHTML should NOT return frozen string
       [not found] <redmine.issue-11858.20151222025600@ruby-lang.org>
@ 2015-12-22  2:56 ` tietew
  2015-12-22  3:09 ` [ruby-core:72427] [Ruby trunk - Bug #11858] " tietew
  2016-02-03 10:45 ` [ruby-core:73674] [Ruby trunk Bug#11858] " usa
  2 siblings, 0 replies; 3+ messages in thread
From: tietew @ 2015-12-22  2:56 UTC (permalink / raw)
  To: ruby-core

Issue #11858 has been reported by Toru Iwase.

----------------------------------------
Bug #11858: CGI.escapeHTML should NOT return frozen string
https://bugs.ruby-lang.org/issues/11858

* Author: Toru Iwase
* Status: Open
* Priority: Normal
* Assignee: 
* ruby -v: ruby 2.3.0dev (2015-12-22 trunk 53233) [x86_64-linux]
* Backport: 2.0.0: UNKNOWN, 2.1: UNKNOWN, 2.2: UNKNOWN
----------------------------------------
After r53220, following snippet fails.

~~~
$ ./ruby -rcgi -ve 'p CGI.escapeHTML("Hello, ".freeze) << "world."'
ruby 2.3.0dev (2015-12-22 trunk 53233) [x86_64-linux]
-e:1:in `<main>': can't modify frozen String (RuntimeError)
~~~

In preview2, works.

~~~
$ RBENV_VERSION=2.3.0-preview2 ruby -rcgi -ve 'p CGI.escapeHTML("Hello, ".freeze) << "world."'
ruby 2.3.0preview2 (2015-12-11 trunk 53028) [x86_64-linux]
"Hello, world."
~~~

I think this is backward incompatibility.
`CGI.escapeHTML` should return different and unfreezed string from passed string as `String#gsub`.

~~~
$ ./irb
ruby 2.3.0dev (2015-12-22 trunk 53233) [x86_64-linux]
irb(main):001:0> str = "Ruby".freeze
=> "Ruby"
irb(main):002:0> str.object_id
=> 70236871355920
irb(main):003:0> str.gsub(/\d/, '').frozen?
=> false
irb(main):004:0> str.gsub(/\d/, '').object_id
=> 70236871220100  # different object
irb(main):006:0> require 'cgi'
=> true
irb(main):007:0> CGI.escapeHTML(str).frozen?
=> true
irb(main):008:0> CGI.escapeHTML(str).object_id
=> 70236871355920  # same object
~~~




-- 
https://bugs.ruby-lang.org/

^ permalink raw reply	[flat|nested] 3+ messages in thread

* [ruby-core:72427] [Ruby trunk - Bug #11858] CGI.escapeHTML should NOT return frozen string
       [not found] <redmine.issue-11858.20151222025600@ruby-lang.org>
  2015-12-22  2:56 ` [ruby-core:72426] [Ruby trunk - Bug #11858] [Open] CGI.escapeHTML should NOT return frozen string tietew
@ 2015-12-22  3:09 ` tietew
  2016-02-03 10:45 ` [ruby-core:73674] [Ruby trunk Bug#11858] " usa
  2 siblings, 0 replies; 3+ messages in thread
From: tietew @ 2015-12-22  3:09 UTC (permalink / raw)
  To: ruby-core

Issue #11858 has been updated by Toru Iwase.

File escapehtml_dup_str.patch added

Attached a suggested patch.
This patch also adds some tests for not-modified patterns.


----------------------------------------
Bug #11858: CGI.escapeHTML should NOT return frozen string
https://bugs.ruby-lang.org/issues/11858#change-55719

* Author: Toru Iwase
* Status: Open
* Priority: Normal
* Assignee: 
* ruby -v: ruby 2.3.0dev (2015-12-22 trunk 53233) [x86_64-linux]
* Backport: 2.0.0: UNKNOWN, 2.1: UNKNOWN, 2.2: UNKNOWN
----------------------------------------
After r53220, following snippet fails.

~~~
$ ./ruby -rcgi -ve 'p CGI.escapeHTML("Hello, ".freeze) << "world."'
ruby 2.3.0dev (2015-12-22 trunk 53233) [x86_64-linux]
-e:1:in `<main>': can't modify frozen String (RuntimeError)
~~~

In preview2, works.

~~~
$ RBENV_VERSION=2.3.0-preview2 ruby -rcgi -ve 'p CGI.escapeHTML("Hello, ".freeze) << "world."'
ruby 2.3.0preview2 (2015-12-11 trunk 53028) [x86_64-linux]
"Hello, world."
~~~

I think this is backward incompatibility.
`CGI.escapeHTML` should return different and unfreezed string from passed string as `String#gsub`.

~~~
$ ./irb
ruby 2.3.0dev (2015-12-22 trunk 53233) [x86_64-linux]
irb(main):001:0> str = "Ruby".freeze
=> "Ruby"
irb(main):002:0> str.object_id
=> 70236871355920
irb(main):003:0> str.gsub(/\d/, '').frozen?
=> false
irb(main):004:0> str.gsub(/\d/, '').object_id
=> 70236871220100  # different object
irb(main):006:0> require 'cgi'
=> true
irb(main):007:0> CGI.escapeHTML(str).frozen?
=> true
irb(main):008:0> CGI.escapeHTML(str).object_id
=> 70236871355920  # same object
~~~


---Files--------------------------------
escapehtml_dup_str.patch (2.06 KB)


-- 
https://bugs.ruby-lang.org/

^ permalink raw reply	[flat|nested] 3+ messages in thread

* [ruby-core:73674] [Ruby trunk Bug#11858] CGI.escapeHTML should NOT return frozen string
       [not found] <redmine.issue-11858.20151222025600@ruby-lang.org>
  2015-12-22  2:56 ` [ruby-core:72426] [Ruby trunk - Bug #11858] [Open] CGI.escapeHTML should NOT return frozen string tietew
  2015-12-22  3:09 ` [ruby-core:72427] [Ruby trunk - Bug #11858] " tietew
@ 2016-02-03 10:45 ` usa
  2 siblings, 0 replies; 3+ messages in thread
From: usa @ 2016-02-03 10:45 UTC (permalink / raw)
  To: ruby-core

Issue #11858 has been updated by Usaku NAKAMURA.

Backport changed from 2.0.0: UNKNOWN, 2.1: UNKNOWN, 2.2: UNKNOWN to 2.0.0: DONTNEED, 2.1: DONTNEED, 2.2: DONTNEED

----------------------------------------
Bug #11858: CGI.escapeHTML should NOT return frozen string
https://bugs.ruby-lang.org/issues/11858#change-56869

* Author: Toru Iwase
* Status: Closed
* Priority: Normal
* Assignee: 
* ruby -v: ruby 2.3.0dev (2015-12-22 trunk 53233) [x86_64-linux]
* Backport: 2.0.0: DONTNEED, 2.1: DONTNEED, 2.2: DONTNEED
----------------------------------------
After r53220, following snippet fails.

~~~
$ ./ruby -rcgi -ve 'p CGI.escapeHTML("Hello, ".freeze) << "world."'
ruby 2.3.0dev (2015-12-22 trunk 53233) [x86_64-linux]
-e:1:in `<main>': can't modify frozen String (RuntimeError)
~~~

In preview2, works.

~~~
$ RBENV_VERSION=2.3.0-preview2 ruby -rcgi -ve 'p CGI.escapeHTML("Hello, ".freeze) << "world."'
ruby 2.3.0preview2 (2015-12-11 trunk 53028) [x86_64-linux]
"Hello, world."
~~~

I think this is backward incompatibility.
`CGI.escapeHTML` should return different and unfreezed string from passed string as `String#gsub`.

~~~
$ ./irb
ruby 2.3.0dev (2015-12-22 trunk 53233) [x86_64-linux]
irb(main):001:0> str = "Ruby".freeze
=> "Ruby"
irb(main):002:0> str.object_id
=> 70236871355920
irb(main):003:0> str.gsub(/\d/, '').frozen?
=> false
irb(main):004:0> str.gsub(/\d/, '').object_id
=> 70236871220100  # different object
irb(main):006:0> require 'cgi'
=> true
irb(main):007:0> CGI.escapeHTML(str).frozen?
=> true
irb(main):008:0> CGI.escapeHTML(str).object_id
=> 70236871355920  # same object
~~~


---Files--------------------------------
escapehtml_dup_str.patch (2.06 KB)


-- 
https://bugs.ruby-lang.org/

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2016-02-03 10:11 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <redmine.issue-11858.20151222025600@ruby-lang.org>
2015-12-22  2:56 ` [ruby-core:72426] [Ruby trunk - Bug #11858] [Open] CGI.escapeHTML should NOT return frozen string tietew
2015-12-22  3:09 ` [ruby-core:72427] [Ruby trunk - Bug #11858] " tietew
2016-02-03 10:45 ` [ruby-core:73674] [Ruby trunk Bug#11858] " usa

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).