cgi 0.3.1 → 0.3.2

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of cgi might be problematic. Click here for more details.

checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 90a6a863562fc49b43b4b3363838cfc00cd4080df4fa1a4939e505d651115ad2
4
- data.tar.gz: 5eeb77d5c5e4a42c8683e6953174483d4c5d7c5c9a61dc78590df100a716985f
3
+ metadata.gz: 670bbf0eb15455e6020b95c0ca39481adb722eb4bb60fc797761b66a8f19af81
4
+ data.tar.gz: 9e360fdb4a408678f9edda5d3a8035e0bf05e087c946593cbac13d21d22f1998
5
5
  SHA512:
6
- metadata.gz: dc300664978f5278e2e366c85acf2ec7929505369c7abaa0ef3d0658e5de556d3eb1c8e66d497c6f8b88efeabcfa57c2871bfbd325dd1e1b72fdcc4edf03defd
7
- data.tar.gz: 7f82863adb49bd898c376d16a5d8ade52c0ada8d5994a22a858e7b47f467a69c755f22d8f691fcc891df222b176d472c167ac3e4b6896b104353fb04da867a56
6
+ metadata.gz: 4115408aa6f5dc3f17b638d9e7fc1ba0e10d4d84172910558c7d01e5ae2bf79fa198111dbd137d1602d2cb8299ae98961ae66f0aaf93bc0cf09912b3565bb664
7
+ data.tar.gz: 0e47613d0b6677a7062a87e6b07c7cefe3957d02fb74ed8c385ad0671146eafb0d26ec9efa29cf619b5e30a45b0c0b2bc259161a66b9dc3f778e5699806ad17a
data/Rakefile CHANGED
@@ -1,20 +1,17 @@
1
1
  require "bundler/gem_tasks"
2
2
  require "rake/testtask"
3
3
 
4
+ require 'rake/extensiontask'
5
+ extask = Rake::ExtensionTask.new("cgi/escape") do |x|
6
+ x.lib_dir.sub!(%r[(?=/|\z)], "/#{RUBY_VERSION}/#{x.platform}")
7
+ end
8
+
4
9
  Rake::TestTask.new(:test) do |t|
10
+ t.libs << "lib/#{RUBY_VERSION}/#{extask.platform}"
5
11
  t.libs << "test/lib"
6
12
  t.ruby_opts << "-rhelper"
7
13
  t.test_files = FileList['test/**/test_*.rb']
8
14
  end
9
15
 
10
- require 'rake/extensiontask'
11
- Rake::ExtensionTask.new("cgi/escape")
12
-
13
- task :sync_tool do
14
- require 'fileutils'
15
- FileUtils.cp "../ruby/tool/lib/core_assertions.rb", "./test/lib"
16
- FileUtils.cp "../ruby/tool/lib/envutil.rb", "./test/lib"
17
- FileUtils.cp "../ruby/tool/lib/find_executable.rb", "./test/lib"
18
- end
19
-
20
16
  task :default => :test
17
+ task :test => :compile
data/cgi.gemspec CHANGED
@@ -23,9 +23,9 @@ Gem::Specification.new do |spec|
23
23
  spec.metadata["source_code_uri"] = spec.homepage
24
24
 
25
25
  spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
26
- `git ls-files -z 2>/dev/null`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
26
+ `git ls-files -z 2>/dev/null`.split("\x0").reject { |f| f.match(%r{\A(?:(?:test|spec|features)/|\.git)}) }
27
27
  end
28
- spec.bindir = "exe"
28
+ spec.extensions = ["ext/cgi/escape/extconf.rb"]
29
29
  spec.executables = []
30
30
  spec.require_paths = ["lib"]
31
31
  end
@@ -1,17 +1,2 @@
1
- # AUTOGENERATED DEPENDENCIES START
2
1
  escape.o: $(RUBY_EXTCONF_H)
3
- escape.o: $(arch_hdrdir)/ruby/config.h
4
- escape.o: $(hdrdir)/ruby.h
5
- escape.o: $(hdrdir)/ruby/assert.h
6
- escape.o: $(hdrdir)/ruby/backward.h
7
- escape.o: $(hdrdir)/ruby/defines.h
8
- escape.o: $(hdrdir)/ruby/encoding.h
9
- escape.o: $(hdrdir)/ruby/intern.h
10
- escape.o: $(hdrdir)/ruby/missing.h
11
- escape.o: $(hdrdir)/ruby/onigmo.h
12
- escape.o: $(hdrdir)/ruby/oniguruma.h
13
- escape.o: $(hdrdir)/ruby/ruby.h
14
- escape.o: $(hdrdir)/ruby/st.h
15
- escape.o: $(hdrdir)/ruby/subst.h
16
2
  escape.o: escape.c
17
- # AUTOGENERATED DEPENDENCIES END
@@ -32,12 +32,21 @@ preserve_original_state(VALUE orig, VALUE dest)
32
32
  rb_enc_associate(dest, rb_enc_get(orig));
33
33
  }
34
34
 
35
+ static inline long
36
+ escaped_length(VALUE str)
37
+ {
38
+ const long len = RSTRING_LEN(str);
39
+ if (len >= LONG_MAX / HTML_ESCAPE_MAX_LEN) {
40
+ ruby_malloc_size_overflow(len, HTML_ESCAPE_MAX_LEN);
41
+ }
42
+ return len * HTML_ESCAPE_MAX_LEN;
43
+ }
44
+
35
45
  static VALUE
36
46
  optimized_escape_html(VALUE str)
37
47
  {
38
48
  VALUE vbuf;
39
- typedef char escape_buf[HTML_ESCAPE_MAX_LEN];
40
- char *buf = *ALLOCV_N(escape_buf, vbuf, RSTRING_LEN(str));
49
+ char *buf = ALLOCV_N(char, vbuf, escaped_length(str));
41
50
  const char *cstr = RSTRING_PTR(str);
42
51
  const char *end = cstr + RSTRING_LEN(str);
43
52
 
@@ -44,20 +44,8 @@ class CGI
44
44
  # This session's PStore file will be created if it does
45
45
  # not exist, or opened if it does.
46
46
  def initialize(session, option={})
47
- dir = option['tmpdir'] || Dir::tmpdir
48
- prefix = option['prefix'] || ''
49
- id = session.session_id
50
- require 'digest/md5'
51
- md5 = Digest::MD5.hexdigest(id)[0,16]
52
- path = dir+"/"+prefix+md5
53
- if File::exist?(path)
54
- @hash = nil
55
- else
56
- unless session.new_session
57
- raise CGI::Session::NoSession, "uninitialized session"
58
- end
59
- @hash = {}
60
- end
47
+ option = {'suffix'=>''}.update(option)
48
+ path, @hash = session.new_store_file(option)
61
49
  @p = ::PStore.new(path)
62
50
  @p.transaction do |p|
63
51
  File.chmod(0600, p.path)
data/lib/cgi/session.rb CHANGED
@@ -189,6 +189,47 @@ class CGI
189
189
  end
190
190
  private :create_new_id
191
191
 
192
+
193
+ # Create a new file to store the session data.
194
+ #
195
+ # This file will be created if it does not exist, or opened if it
196
+ # does.
197
+ #
198
+ # This path is generated under _tmpdir_ from _prefix_, the
199
+ # digested session id, and _suffix_.
200
+ #
201
+ # +option+ is a hash of options for the initializer. The
202
+ # following options are recognised:
203
+ #
204
+ # tmpdir:: the directory to use for storing the FileStore
205
+ # file. Defaults to Dir::tmpdir (generally "/tmp"
206
+ # on Unix systems).
207
+ # prefix:: the prefix to add to the session id when generating
208
+ # the filename for this session's FileStore file.
209
+ # Defaults to "cgi_sid_".
210
+ # suffix:: the prefix to add to the session id when generating
211
+ # the filename for this session's FileStore file.
212
+ # Defaults to the empty string.
213
+ def new_store_file(option={}) # :nodoc:
214
+ dir = option['tmpdir'] || Dir::tmpdir
215
+ prefix = option['prefix']
216
+ suffix = option['suffix']
217
+ require 'digest/md5'
218
+ md5 = Digest::MD5.hexdigest(session_id)[0,16]
219
+ path = dir+"/"
220
+ path << prefix if prefix
221
+ path << md5
222
+ path << suffix if suffix
223
+ if File::exist? path
224
+ hash = nil
225
+ elsif new_session
226
+ hash = {}
227
+ else
228
+ raise NoSession, "uninitialized session"
229
+ end
230
+ return path, hash
231
+ end
232
+
192
233
  # Create a new CGI::Session object for +request+.
193
234
  #
194
235
  # +request+ is an instance of the +CGI+ class (see cgi.rb).
@@ -373,21 +414,8 @@ class CGI
373
414
  # This session's FileStore file will be created if it does
374
415
  # not exist, or opened if it does.
375
416
  def initialize(session, option={})
376
- dir = option['tmpdir'] || Dir::tmpdir
377
- prefix = option['prefix'] || 'cgi_sid_'
378
- suffix = option['suffix'] || ''
379
- id = session.session_id
380
- require 'digest/md5'
381
- md5 = Digest::MD5.hexdigest(id)[0,16]
382
- @path = dir+"/"+prefix+md5+suffix
383
- if File::exist? @path
384
- @hash = nil
385
- else
386
- unless session.new_session
387
- raise CGI::Session::NoSession, "uninitialized session"
388
- end
389
- @hash = {}
390
- end
417
+ option = {'prefix' => 'cgi_sid_'}.update(option)
418
+ @path, @hash = session.new_store_file(option)
391
419
  end
392
420
 
393
421
  # Restore session state from the session's FileStore file.
data/lib/cgi.rb CHANGED
@@ -288,7 +288,7 @@
288
288
  #
289
289
 
290
290
  class CGI
291
- VERSION = "0.3.1"
291
+ VERSION = "0.3.2"
292
292
  end
293
293
 
294
294
  require 'cgi/core'
@@ -0,0 +1,34 @@
1
+ task "build" => "changelogs"
2
+
3
+ changelog = proc do |output, ver = nil, prev = nil|
4
+ ver &&= Gem::Version.new(ver)
5
+ range = [[prev], [ver, "HEAD"]].map {|ver, branch| ver ? "v#{ver.to_s}" : branch}.compact.join("..")
6
+ IO.popen(%W[git log --format=fuller --topo-order --no-merges #{range}]) do |log|
7
+ line = log.gets
8
+ FileUtils.mkpath(File.dirname(output))
9
+ File.open(output, "wb") do |f|
10
+ f.print "-*- coding: utf-8 -*-\n\n", line
11
+ log.each_line do |line|
12
+ line.sub!(/^(?!:)(?:Author|Commit)?(?:Date)?: /, ' \&')
13
+ line.sub!(/ +$/, '')
14
+ f.print(line)
15
+ end
16
+ end
17
+ end
18
+ end
19
+
20
+ tags = IO.popen(%w[git tag -l v[0-9]*]).grep(/v(.*)/) {$1}
21
+ tags.sort_by! {|tag| tag.scan(/\d+/).map(&:to_i)}
22
+ tags.inject(nil) do |prev, tag|
23
+ task("logs/ChangeLog-#{tag}") {|t| changelog[t.name, tag, prev]}
24
+ tag
25
+ end
26
+
27
+ desc "Make ChangeLog"
28
+ task "ChangeLog", [:ver, :prev] do |t, ver: nil, prev: tags.last|
29
+ changelog[t.name, ver, prev]
30
+ end
31
+
32
+ changelogs = ["ChangeLog", *tags.map {|tag| "logs/ChangeLog-#{tag}"}]
33
+ task "changelogs" => changelogs
34
+ CLOBBER.concat(changelogs) << "logs"
@@ -0,0 +1,5 @@
1
+ task "build" => "date_epoch"
2
+
3
+ task "date_epoch" do
4
+ ENV["SOURCE_DATE_EPOCH"] = IO.popen(%W[git -C #{__dir__} log -1 --format=%ct], &:read).chomp
5
+ end
@@ -0,0 +1,6 @@
1
+ task :sync_tool do
2
+ require 'fileutils'
3
+ FileUtils.cp "../ruby/tool/lib/core_assertions.rb", "./test/lib"
4
+ FileUtils.cp "../ruby/tool/lib/envutil.rb", "./test/lib"
5
+ FileUtils.cp "../ruby/tool/lib/find_executable.rb", "./test/lib"
6
+ end
@@ -0,0 +1,44 @@
1
+ class << (helper = Bundler::GemHelper.instance)
2
+ def update_gemspec
3
+ path = gemspec.loaded_from
4
+ File.open(path, "r+b") do |f|
5
+ d = f.read
6
+ if d.sub!(/^(_VERSION\s*=\s*)".*"/) {$1 + gemspec.version.to_s.dump}
7
+ f.rewind
8
+ f.truncate(0)
9
+ f.print(d)
10
+ end
11
+ end
12
+ end
13
+
14
+ def commit_bump
15
+ sh(%W[git commit -m bump\ up\ to\ #{gemspec.version}
16
+ #{gemspec.loaded_from}])
17
+ end
18
+
19
+ def version=(v)
20
+ gemspec.version = v
21
+ update_gemspec
22
+ commit_bump
23
+ end
24
+ end
25
+
26
+ major, minor, teeny = helper.gemspec.version.segments
27
+
28
+ task "bump:teeny" do
29
+ helper.version = Gem::Version.new("#{major}.#{minor}.#{teeny+1}")
30
+ end
31
+
32
+ task "bump:minor" do
33
+ helper.version = Gem::Version.new("#{major}.#{minor+1}.0")
34
+ end
35
+
36
+ task "bump:major" do
37
+ helper.version = Gem::Version.new("#{major+1}.0.0")
38
+ end
39
+
40
+ task "bump" => "bump:teeny"
41
+
42
+ task "tag" do
43
+ helper.__send__(:tag_version)
44
+ end
metadata CHANGED
@@ -1,30 +1,27 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cgi
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.1
4
+ version: 0.3.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Yukihiro Matsumoto
8
- autorequire:
9
- bindir: exe
8
+ autorequire:
9
+ bindir: bin
10
10
  cert_chain: []
11
- date: 2021-11-24 00:00:00.000000000 Z
11
+ date: 2022-03-03 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: Support for the Common Gateway Interface protocol.
14
14
  email:
15
15
  - matz@ruby-lang.org
16
16
  executables: []
17
- extensions: []
17
+ extensions:
18
+ - ext/cgi/escape/extconf.rb
18
19
  extra_rdoc_files: []
19
20
  files:
20
- - ".github/workflows/test.yml"
21
- - ".gitignore"
22
21
  - Gemfile
23
22
  - LICENSE.txt
24
23
  - README.md
25
24
  - Rakefile
26
- - bin/console
27
- - bin/setup
28
25
  - cgi.gemspec
29
26
  - ext/cgi/escape/depend
30
27
  - ext/cgi/escape/escape.c
@@ -36,6 +33,10 @@ files:
36
33
  - lib/cgi/session.rb
37
34
  - lib/cgi/session/pstore.rb
38
35
  - lib/cgi/util.rb
36
+ - rakelib/changelogs.rake
37
+ - rakelib/epoch.rake
38
+ - rakelib/sync_tool.rake
39
+ - rakelib/version.rake
39
40
  homepage: https://github.com/ruby/cgi
40
41
  licenses:
41
42
  - Ruby
@@ -43,7 +44,7 @@ licenses:
43
44
  metadata:
44
45
  homepage_uri: https://github.com/ruby/cgi
45
46
  source_code_uri: https://github.com/ruby/cgi
46
- post_install_message:
47
+ post_install_message:
47
48
  rdoc_options: []
48
49
  require_paths:
49
50
  - lib
@@ -58,8 +59,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
58
59
  - !ruby/object:Gem::Version
59
60
  version: '0'
60
61
  requirements: []
61
- rubygems_version: 3.3.0.dev
62
- signing_key:
62
+ rubygems_version: 3.4.0.dev
63
+ signing_key:
63
64
  specification_version: 4
64
65
  summary: Support for the Common Gateway Interface protocol.
65
66
  test_files: []
@@ -1,22 +0,0 @@
1
- name: test
2
-
3
- on: [push, pull_request]
4
-
5
- jobs:
6
- build:
7
- name: build (${{ matrix.ruby }} / ${{ matrix.os }})
8
- strategy:
9
- matrix:
10
- ruby: [ '3.0', 2.7, 2.6, 2.5, head ]
11
- os: [ ubuntu-latest, macos-latest ]
12
- runs-on: ${{ matrix.os }}
13
- steps:
14
- - uses: actions/checkout@v2
15
- - name: Set up Ruby
16
- uses: ruby/setup-ruby@v1
17
- with:
18
- ruby-version: ${{ matrix.ruby }}
19
- - name: Install dependencies
20
- run: bundle install
21
- - name: Run test
22
- run: rake test
data/.gitignore DELETED
@@ -1,12 +0,0 @@
1
- /.bundle/
2
- /.yardoc
3
- /_yardoc/
4
- /coverage/
5
- /doc/
6
- /pkg/
7
- /spec/reports/
8
- /tmp/
9
- /Gemfile.lock
10
- *.bundle
11
- *.so
12
- *.dll
data/bin/console DELETED
@@ -1,7 +0,0 @@
1
- #!/usr/bin/env ruby
2
-
3
- require "bundler/setup"
4
- require "cgi"
5
-
6
- require "irb"
7
- IRB.start(__FILE__)
data/bin/setup DELETED
@@ -1,6 +0,0 @@
1
- #!/usr/bin/env bash
2
- set -euo pipefail
3
- IFS=$'\n\t'
4
- set -vx
5
-
6
- bundle install