ruby-dev (Japanese) list archive (unofficial mirror)
 help / color / mirror / Atom feed
* [ruby-dev:49479] [Ruby trunk - Bug #11972] [Open] CGI::pretty がコメント内のhtmlタグにより範囲を見失う
       [not found] <redmine.issue-11972.20160110131240@ruby-lang.org>
@ 2016-01-10 13:12 ` koshian
  2019-07-24 16:58 ` [ruby-dev:50819] [Ruby master Bug#11972] " merch-redmine
  1 sibling, 0 replies; 2+ messages in thread
From: koshian @ 2016-01-10 13:12 UTC (permalink / raw)
  To: ruby-dev

Issue #11972 has been reported by Sugano Yoshihisa.

----------------------------------------
Bug #11972: CGI::pretty がコメント内のhtmlタグにより範囲を見失う
https://bugs.ruby-lang.org/issues/11972

* Author: Sugano Yoshihisa
* Status: Open
* Priority: Normal
* Assignee: 
* ruby -v: ruby 2.0.0p645 (2015-04-13 revision 50299) [universal.x86_64-darwin15]
* Backport: 2.0.0: UNKNOWN, 2.1: UNKNOWN, 2.2: UNKNOWN, 2.3: UNKNOWN
----------------------------------------
以下のようなコードで ArgumentError が再現します。

~~~
#!/usr/bin/env ruby
require 'cgi'
puts CGI.pretty(DATA.read)
__END__
<script>
// <!--
  alert('<p></p>');
// -->
</script>
~~~

手元では CGI::pretty の1行目を

lines = string.gsub(/(?!\A)<[^!]*?>/m, "\n\\0").gsub(/<.*?>(?!\n)/m, "\\0\n")

というようにしてコメントを無視させることで回避してみました。

はてなブログの html コードをそのまま読ませて気づいたのですが、script 要素内で
html を挿入していたりすると発生するようです。



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

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

* [ruby-dev:50819] [Ruby master Bug#11972] CGI::pretty がコメント内のhtmlタグにより範囲を見失う
       [not found] <redmine.issue-11972.20160110131240@ruby-lang.org>
  2016-01-10 13:12 ` [ruby-dev:49479] [Ruby trunk - Bug #11972] [Open] CGI::pretty がコメント内のhtmlタグにより範囲を見失う koshian
@ 2019-07-24 16:58 ` merch-redmine
  1 sibling, 0 replies; 2+ messages in thread
From: merch-redmine @ 2019-07-24 16:58 UTC (permalink / raw)
  To: ruby-dev

Issue #11972 has been updated by jeremyevans0 (Jeremy Evans).

Status changed from Open to Closed

This was fixed between 2.6 and 2.7.0-preview1:

```
$ ruby26 t/t.rb
Traceback (most recent call last):
        1: from t/t.rb:2:in `<main>'
/usr/local/lib/ruby/2.6/cgi/util.rb:217:in `pretty': bad value for range (ArgumentError)
$ ruby27 t/t.rb
____<script>
    //
    <!--
      alert('<p>
  </p>
  ');
  // -->

</script>
```

----------------------------------------
Bug #11972: CGI::pretty がコメント内のhtmlタグにより範囲を見失う
https://bugs.ruby-lang.org/issues/11972#change-79952

* Author: koshian (Sugano Yoshihisa)
* Status: Closed
* Priority: Normal
* Assignee: 
* Target version: 
* ruby -v: ruby 2.0.0p645 (2015-04-13 revision 50299) [universal.x86_64-darwin15]
* Backport: 2.0.0: UNKNOWN, 2.1: UNKNOWN, 2.2: UNKNOWN, 2.3: UNKNOWN
----------------------------------------
以下のようなコードで ArgumentError が再現します。

~~~
#!/usr/bin/env ruby
require 'cgi'
puts CGI.pretty(DATA.read)
__END__
<script>
// <!--
  alert('<p></p>');
// -->
</script>
~~~

手元では CGI::pretty の1行目を

lines = string.gsub(/(?!\A)<[^!]*?>/m, "\n\\0").gsub(/<.*?>(?!\n)/m, "\\0\n")

というようにしてコメントを無視させることで回避してみました。

はてなブログの html コードをそのまま読ませて気づいたのですが、script 要素内で
html を挿入していたりすると発生するようです。



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

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

end of thread, other threads:[~2019-07-24 16:59 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <redmine.issue-11972.20160110131240@ruby-lang.org>
2016-01-10 13:12 ` [ruby-dev:49479] [Ruby trunk - Bug #11972] [Open] CGI::pretty がコメント内のhtmlタグにより範囲を見失う koshian
2019-07-24 16:58 ` [ruby-dev:50819] [Ruby master Bug#11972] " merch-redmine

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).