ey-deploy 0.9.1 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/ey-deploy.rb +5 -2
- data/lib/ey-deploy/cli.rb +2 -2
- data/lib/ey-deploy/deploy.rb +8 -1
- data/lib/ey-deploy/logged_output.rb +6 -0
- data/lib/ey-deploy/strategies/git.rb +5 -4
- data/lib/ey-deploy/version.rb +1 -1
- data/lib/vendor/escape/Readme +21 -0
- data/lib/vendor/escape/doc_include/template/qualitysmith.rb +631 -0
- data/lib/vendor/escape/lib/escape.rb +247 -0
- data/lib/vendor/json_pure/CHANGES +166 -0
- data/lib/vendor/json_pure/COPYING +58 -0
- data/lib/vendor/json_pure/GPL +340 -0
- data/lib/vendor/json_pure/README +358 -0
- data/lib/vendor/json_pure/Rakefile +292 -0
- data/lib/vendor/json_pure/TODO +1 -0
- data/lib/vendor/json_pure/VERSION +1 -0
- data/lib/vendor/json_pure/benchmarks/data-p4-3GHz-ruby18/GeneratorBenchmarkComparison.log +52 -0
- data/lib/vendor/json_pure/benchmarks/data-p4-3GHz-ruby18/GeneratorBenchmarkExt#generator_fast-autocorrelation.dat +1000 -0
- data/lib/vendor/json_pure/benchmarks/data-p4-3GHz-ruby18/GeneratorBenchmarkExt#generator_fast.dat +1001 -0
- data/lib/vendor/json_pure/benchmarks/data-p4-3GHz-ruby18/GeneratorBenchmarkExt#generator_pretty-autocorrelation.dat +900 -0
- data/lib/vendor/json_pure/benchmarks/data-p4-3GHz-ruby18/GeneratorBenchmarkExt#generator_pretty.dat +901 -0
- data/lib/vendor/json_pure/benchmarks/data-p4-3GHz-ruby18/GeneratorBenchmarkExt#generator_safe-autocorrelation.dat +1000 -0
- data/lib/vendor/json_pure/benchmarks/data-p4-3GHz-ruby18/GeneratorBenchmarkExt#generator_safe.dat +1001 -0
- data/lib/vendor/json_pure/benchmarks/data-p4-3GHz-ruby18/GeneratorBenchmarkExt.log +261 -0
- data/lib/vendor/json_pure/benchmarks/data-p4-3GHz-ruby18/GeneratorBenchmarkPure#generator_fast-autocorrelation.dat +1000 -0
- data/lib/vendor/json_pure/benchmarks/data-p4-3GHz-ruby18/GeneratorBenchmarkPure#generator_fast.dat +1001 -0
- data/lib/vendor/json_pure/benchmarks/data-p4-3GHz-ruby18/GeneratorBenchmarkPure#generator_pretty-autocorrelation.dat +1000 -0
- data/lib/vendor/json_pure/benchmarks/data-p4-3GHz-ruby18/GeneratorBenchmarkPure#generator_pretty.dat +1001 -0
- data/lib/vendor/json_pure/benchmarks/data-p4-3GHz-ruby18/GeneratorBenchmarkPure#generator_safe-autocorrelation.dat +1000 -0
- data/lib/vendor/json_pure/benchmarks/data-p4-3GHz-ruby18/GeneratorBenchmarkPure#generator_safe.dat +1001 -0
- data/lib/vendor/json_pure/benchmarks/data-p4-3GHz-ruby18/GeneratorBenchmarkPure.log +262 -0
- data/lib/vendor/json_pure/benchmarks/data-p4-3GHz-ruby18/GeneratorBenchmarkRails#generator-autocorrelation.dat +1000 -0
- data/lib/vendor/json_pure/benchmarks/data-p4-3GHz-ruby18/GeneratorBenchmarkRails#generator.dat +1001 -0
- data/lib/vendor/json_pure/benchmarks/data-p4-3GHz-ruby18/GeneratorBenchmarkRails.log +82 -0
- data/lib/vendor/json_pure/benchmarks/data-p4-3GHz-ruby18/ParserBenchmarkComparison.log +34 -0
- data/lib/vendor/json_pure/benchmarks/data-p4-3GHz-ruby18/ParserBenchmarkExt#parser-autocorrelation.dat +900 -0
- data/lib/vendor/json_pure/benchmarks/data-p4-3GHz-ruby18/ParserBenchmarkExt#parser.dat +901 -0
- data/lib/vendor/json_pure/benchmarks/data-p4-3GHz-ruby18/ParserBenchmarkExt.log +81 -0
- data/lib/vendor/json_pure/benchmarks/data-p4-3GHz-ruby18/ParserBenchmarkPure#parser-autocorrelation.dat +1000 -0
- data/lib/vendor/json_pure/benchmarks/data-p4-3GHz-ruby18/ParserBenchmarkPure#parser.dat +1001 -0
- data/lib/vendor/json_pure/benchmarks/data-p4-3GHz-ruby18/ParserBenchmarkPure.log +82 -0
- data/lib/vendor/json_pure/benchmarks/data-p4-3GHz-ruby18/ParserBenchmarkRails#parser-autocorrelation.dat +1000 -0
- data/lib/vendor/json_pure/benchmarks/data-p4-3GHz-ruby18/ParserBenchmarkRails#parser.dat +1001 -0
- data/lib/vendor/json_pure/benchmarks/data-p4-3GHz-ruby18/ParserBenchmarkRails.log +82 -0
- data/lib/vendor/json_pure/benchmarks/data-p4-3GHz-ruby18/ParserBenchmarkYAML#parser-autocorrelation.dat +1000 -0
- data/lib/vendor/json_pure/benchmarks/data-p4-3GHz-ruby18/ParserBenchmarkYAML#parser.dat +1001 -0
- data/lib/vendor/json_pure/benchmarks/data-p4-3GHz-ruby18/ParserBenchmarkYAML.log +82 -0
- data/lib/vendor/json_pure/benchmarks/generator2_benchmark.rb +222 -0
- data/lib/vendor/json_pure/benchmarks/generator_benchmark.rb +224 -0
- data/lib/vendor/json_pure/benchmarks/ohai.json +1216 -0
- data/lib/vendor/json_pure/benchmarks/ohai.ruby +1 -0
- data/lib/vendor/json_pure/benchmarks/parser2_benchmark.rb +251 -0
- data/lib/vendor/json_pure/benchmarks/parser_benchmark.rb +259 -0
- data/lib/vendor/json_pure/bin/edit_json.rb +9 -0
- data/lib/vendor/json_pure/bin/prettify_json.rb +75 -0
- data/lib/vendor/json_pure/data/example.json +1 -0
- data/lib/vendor/json_pure/data/index.html +38 -0
- data/lib/vendor/json_pure/data/prototype.js +4184 -0
- data/lib/vendor/json_pure/ext/json/ext/generator/extconf.rb +16 -0
- data/lib/vendor/json_pure/ext/json/ext/generator/generator.c +1323 -0
- data/lib/vendor/json_pure/ext/json/ext/generator/generator.h +170 -0
- data/lib/vendor/json_pure/ext/json/ext/parser/extconf.rb +15 -0
- data/lib/vendor/json_pure/ext/json/ext/parser/parser.c +1935 -0
- data/lib/vendor/json_pure/ext/json/ext/parser/parser.h +71 -0
- data/lib/vendor/json_pure/ext/json/ext/parser/parser.rl +792 -0
- data/lib/vendor/json_pure/install.rb +26 -0
- data/lib/vendor/json_pure/lib/json.rb +10 -0
- data/lib/vendor/json_pure/lib/json/Array.xpm +21 -0
- data/lib/vendor/json_pure/lib/json/FalseClass.xpm +21 -0
- data/lib/vendor/json_pure/lib/json/Hash.xpm +21 -0
- data/lib/vendor/json_pure/lib/json/Key.xpm +73 -0
- data/lib/vendor/json_pure/lib/json/NilClass.xpm +21 -0
- data/lib/vendor/json_pure/lib/json/Numeric.xpm +28 -0
- data/lib/vendor/json_pure/lib/json/String.xpm +96 -0
- data/lib/vendor/json_pure/lib/json/TrueClass.xpm +21 -0
- data/lib/vendor/json_pure/lib/json/add/core.rb +148 -0
- data/lib/vendor/json_pure/lib/json/add/rails.rb +58 -0
- data/lib/vendor/json_pure/lib/json/common.rb +397 -0
- data/lib/vendor/json_pure/lib/json/editor.rb +1371 -0
- data/lib/vendor/json_pure/lib/json/ext.rb +15 -0
- data/lib/vendor/json_pure/lib/json/json.xpm +1499 -0
- data/lib/vendor/json_pure/lib/json/pure.rb +77 -0
- data/lib/vendor/json_pure/lib/json/pure/generator.rb +452 -0
- data/lib/vendor/json_pure/lib/json/pure/parser.rb +307 -0
- data/lib/vendor/json_pure/lib/json/version.rb +8 -0
- data/lib/vendor/json_pure/tests/fixtures/fail1.json +1 -0
- data/lib/vendor/json_pure/tests/fixtures/fail10.json +1 -0
- data/lib/vendor/json_pure/tests/fixtures/fail11.json +1 -0
- data/lib/vendor/json_pure/tests/fixtures/fail12.json +1 -0
- data/lib/vendor/json_pure/tests/fixtures/fail13.json +1 -0
- data/lib/vendor/json_pure/tests/fixtures/fail14.json +1 -0
- data/lib/vendor/json_pure/tests/fixtures/fail18.json +1 -0
- data/lib/vendor/json_pure/tests/fixtures/fail19.json +1 -0
- data/lib/vendor/json_pure/tests/fixtures/fail2.json +1 -0
- data/lib/vendor/json_pure/tests/fixtures/fail20.json +1 -0
- data/lib/vendor/json_pure/tests/fixtures/fail21.json +1 -0
- data/lib/vendor/json_pure/tests/fixtures/fail22.json +1 -0
- data/lib/vendor/json_pure/tests/fixtures/fail23.json +1 -0
- data/lib/vendor/json_pure/tests/fixtures/fail24.json +1 -0
- data/lib/vendor/json_pure/tests/fixtures/fail25.json +1 -0
- data/lib/vendor/json_pure/tests/fixtures/fail27.json +2 -0
- data/lib/vendor/json_pure/tests/fixtures/fail28.json +2 -0
- data/lib/vendor/json_pure/tests/fixtures/fail3.json +1 -0
- data/lib/vendor/json_pure/tests/fixtures/fail4.json +1 -0
- data/lib/vendor/json_pure/tests/fixtures/fail5.json +1 -0
- data/lib/vendor/json_pure/tests/fixtures/fail6.json +1 -0
- data/lib/vendor/json_pure/tests/fixtures/fail7.json +1 -0
- data/lib/vendor/json_pure/tests/fixtures/fail8.json +1 -0
- data/lib/vendor/json_pure/tests/fixtures/fail9.json +1 -0
- data/lib/vendor/json_pure/tests/fixtures/pass1.json +56 -0
- data/lib/vendor/json_pure/tests/fixtures/pass15.json +1 -0
- data/lib/vendor/json_pure/tests/fixtures/pass16.json +1 -0
- data/lib/vendor/json_pure/tests/fixtures/pass17.json +1 -0
- data/lib/vendor/json_pure/tests/fixtures/pass2.json +1 -0
- data/lib/vendor/json_pure/tests/fixtures/pass26.json +1 -0
- data/lib/vendor/json_pure/tests/fixtures/pass3.json +6 -0
- data/lib/vendor/json_pure/tests/test_json.rb +361 -0
- data/lib/vendor/json_pure/tests/test_json_addition.rb +162 -0
- data/lib/vendor/json_pure/tests/test_json_encoding.rb +68 -0
- data/lib/vendor/json_pure/tests/test_json_fixtures.rb +34 -0
- data/lib/vendor/json_pure/tests/test_json_generate.rb +122 -0
- data/lib/vendor/json_pure/tests/test_json_rails.rb +144 -0
- data/lib/vendor/json_pure/tests/test_json_unicode.rb +76 -0
- data/lib/vendor/json_pure/tools/fuzz.rb +139 -0
- data/lib/vendor/json_pure/tools/server.rb +61 -0
- metadata +125 -43
@@ -0,0 +1,247 @@
|
|
1
|
+
# escape.rb - escape/unescape library for several formats
|
2
|
+
#
|
3
|
+
# Copyright (C) 2006,2007 Tanaka Akira <akr@fsij.org>
|
4
|
+
#
|
5
|
+
# Redistribution and use in source and binary forms, with or without
|
6
|
+
# modification, are permitted provided that the following conditions are met:
|
7
|
+
#
|
8
|
+
# 1. Redistributions of source code must retain the above copyright notice, this
|
9
|
+
# list of conditions and the following disclaimer.
|
10
|
+
# 2. Redistributions in binary form must reproduce the above copyright notice,
|
11
|
+
# this list of conditions and the following disclaimer in the documentation
|
12
|
+
# and/or other materials provided with the distribution.
|
13
|
+
# 3. The name of the author may not be used to endorse or promote products
|
14
|
+
# derived from this software without specific prior written permission.
|
15
|
+
#
|
16
|
+
# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
17
|
+
# WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
18
|
+
# MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
|
19
|
+
# EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
20
|
+
# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
|
21
|
+
# OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
22
|
+
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
23
|
+
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
|
24
|
+
# IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
|
25
|
+
# OF SUCH DAMAGE.
|
26
|
+
|
27
|
+
# Escape module provides several escape functions.
|
28
|
+
# * URI
|
29
|
+
# * HTML
|
30
|
+
# * shell command
|
31
|
+
module Escape
|
32
|
+
module_function
|
33
|
+
|
34
|
+
# Escape.shell_command composes
|
35
|
+
# a sequence of words to
|
36
|
+
# a single shell command line.
|
37
|
+
# All shell meta characters are quoted and
|
38
|
+
# the words are concatenated with interleaving space.
|
39
|
+
#
|
40
|
+
# Escape.shell_command(["ls", "/"]) #=> "ls /"
|
41
|
+
# Escape.shell_command(["echo", "*"]) #=> "echo '*'"
|
42
|
+
#
|
43
|
+
# Note that system(*command) and
|
44
|
+
# system(Escape.shell_command(command)) is roughly same.
|
45
|
+
# There are two exception as follows.
|
46
|
+
# * The first is that the later may invokes /bin/sh.
|
47
|
+
# * The second is an interpretation of an array with only one element:
|
48
|
+
# the element is parsed by the shell with the former but
|
49
|
+
# it is recognized as single word with the later.
|
50
|
+
# For example, system(*["echo foo"]) invokes echo command with an argument "foo".
|
51
|
+
# But system(Escape.shell_command(["echo foo"])) invokes "echo foo" command without arguments (and it probably fails).
|
52
|
+
def shell_command(command)
|
53
|
+
command.map {|word| shell_single_word(word) }.join(' ')
|
54
|
+
end
|
55
|
+
|
56
|
+
# Escape.shell_single_word quotes shell meta characters.
|
57
|
+
#
|
58
|
+
# The result string is always single shell word, even if
|
59
|
+
# the argument is "".
|
60
|
+
# Escape.shell_single_word("") returns "''".
|
61
|
+
#
|
62
|
+
# Escape.shell_single_word("") #=> "''"
|
63
|
+
# Escape.shell_single_word("foo") #=> "foo"
|
64
|
+
# Escape.shell_single_word("*") #=> "'*'"
|
65
|
+
def shell_single_word(str)
|
66
|
+
if str.empty?
|
67
|
+
"''"
|
68
|
+
elsif %r{\A[0-9A-Za-z+,./:=@_-]+\z} =~ str
|
69
|
+
str
|
70
|
+
else
|
71
|
+
result = ''
|
72
|
+
str.scan(/('+)|[^']+/) {
|
73
|
+
if $1
|
74
|
+
result << %q{\'} * $1.length
|
75
|
+
else
|
76
|
+
result << "'#{$&}'"
|
77
|
+
end
|
78
|
+
}
|
79
|
+
result
|
80
|
+
end
|
81
|
+
end
|
82
|
+
|
83
|
+
# Escape.uri_segment escapes URI segment using percent-encoding.
|
84
|
+
#
|
85
|
+
# Escape.uri_segment("a/b") #=> "a%2Fb"
|
86
|
+
#
|
87
|
+
# The segment is "/"-splitted element after authority before query in URI, as follows.
|
88
|
+
#
|
89
|
+
# scheme://authority/segment1/segment2/.../segmentN?query#fragment
|
90
|
+
#
|
91
|
+
# See RFC 3986 for details of URI.
|
92
|
+
def uri_segment(str)
|
93
|
+
# pchar - pct-encoded = unreserved / sub-delims / ":" / "@"
|
94
|
+
# unreserved = ALPHA / DIGIT / "-" / "." / "_" / "~"
|
95
|
+
# sub-delims = "!" / "$" / "&" / "'" / "(" / ")" / "*" / "+" / "," / ";" / "="
|
96
|
+
str.gsub(%r{[^A-Za-z0-9\-._~!$&'()*+,;=:@]}n) {
|
97
|
+
'%' + $&.unpack("H2")[0].upcase
|
98
|
+
}
|
99
|
+
end
|
100
|
+
|
101
|
+
# Escape.uri_path escapes URI path using percent-encoding.
|
102
|
+
# The given path should be a sequence of (non-escaped) segments separated by "/".
|
103
|
+
# The segments cannot contains "/".
|
104
|
+
#
|
105
|
+
# Escape.uri_path("a/b/c") #=> "a/b/c"
|
106
|
+
# Escape.uri_path("a?b/c?d/e?f") #=> "a%3Fb/c%3Fd/e%3Ff"
|
107
|
+
#
|
108
|
+
# The path is the part after authority before query in URI, as follows.
|
109
|
+
#
|
110
|
+
# scheme://authority/path#fragment
|
111
|
+
#
|
112
|
+
# See RFC 3986 for details of URI.
|
113
|
+
#
|
114
|
+
# Note that this function is not appropriate to convert OS path to URI.
|
115
|
+
def uri_path(str)
|
116
|
+
str.gsub(%r{[^/]+}n) { uri_segment($&) }
|
117
|
+
end
|
118
|
+
|
119
|
+
# :stopdoc:
|
120
|
+
def html_form_fast(pairs, sep=';')
|
121
|
+
pairs.map {|k, v|
|
122
|
+
# query-chars - pct-encoded - x-www-form-urlencoded-delimiters =
|
123
|
+
# unreserved / "!" / "$" / "'" / "(" / ")" / "*" / "," / ":" / "@" / "/" / "?"
|
124
|
+
# query-char - pct-encoded = unreserved / sub-delims / ":" / "@" / "/" / "?"
|
125
|
+
# query-char = pchar / "/" / "?" = unreserved / pct-encoded / sub-delims / ":" / "@" / "/" / "?"
|
126
|
+
# unreserved = ALPHA / DIGIT / "-" / "." / "_" / "~"
|
127
|
+
# sub-delims = "!" / "$" / "&" / "'" / "(" / ")" / "*" / "+" / "," / ";" / "="
|
128
|
+
# x-www-form-urlencoded-delimiters = "&" / "+" / ";" / "="
|
129
|
+
k = k.gsub(%r{[^0-9A-Za-z\-\._~:/?@!\$'()*,]}n) {
|
130
|
+
'%' + $&.unpack("H2")[0].upcase
|
131
|
+
}
|
132
|
+
v = v.gsub(%r{[^0-9A-Za-z\-\._~:/?@!\$'()*,]}n) {
|
133
|
+
'%' + $&.unpack("H2")[0].upcase
|
134
|
+
}
|
135
|
+
"#{k}=#{v}"
|
136
|
+
}.join(sep)
|
137
|
+
end
|
138
|
+
# :startdoc:
|
139
|
+
|
140
|
+
# Escape.html_form composes HTML form key-value pairs as a x-www-form-urlencoded encoded string.
|
141
|
+
#
|
142
|
+
# Escape.html_form takes an array of pair of strings or
|
143
|
+
# an hash from string to string.
|
144
|
+
#
|
145
|
+
# Escape.html_form([["a","b"], ["c","d"]]) #=> "a=b&c=d"
|
146
|
+
# Escape.html_form({"a"=>"b", "c"=>"d"}) #=> "a=b&c=d"
|
147
|
+
#
|
148
|
+
# In the array form, it is possible to use same key more than once.
|
149
|
+
# (It is required for a HTML form which contains
|
150
|
+
# checkboxes and select element with multiple attribute.)
|
151
|
+
#
|
152
|
+
# Escape.html_form([["k","1"], ["k","2"]]) #=> "k=1&k=2"
|
153
|
+
#
|
154
|
+
# If the strings contains characters which must be escaped in x-www-form-urlencoded,
|
155
|
+
# they are escaped using %-encoding.
|
156
|
+
#
|
157
|
+
# Escape.html_form([["k=","&;="]]) #=> "k%3D=%26%3B%3D"
|
158
|
+
#
|
159
|
+
# The separator can be specified by the optional second argument.
|
160
|
+
#
|
161
|
+
# Escape.html_form([["a","b"], ["c","d"]], ";") #=> "a=b;c=d"
|
162
|
+
#
|
163
|
+
# See HTML 4.01 for details.
|
164
|
+
def html_form(pairs, sep='&')
|
165
|
+
r = ''
|
166
|
+
first = true
|
167
|
+
pairs.each {|k, v|
|
168
|
+
# query-chars - pct-encoded - x-www-form-urlencoded-delimiters =
|
169
|
+
# unreserved / "!" / "$" / "'" / "(" / ")" / "*" / "," / ":" / "@" / "/" / "?"
|
170
|
+
# query-char - pct-encoded = unreserved / sub-delims / ":" / "@" / "/" / "?"
|
171
|
+
# query-char = pchar / "/" / "?" = unreserved / pct-encoded / sub-delims / ":" / "@" / "/" / "?"
|
172
|
+
# unreserved = ALPHA / DIGIT / "-" / "." / "_" / "~"
|
173
|
+
# sub-delims = "!" / "$" / "&" / "'" / "(" / ")" / "*" / "+" / "," / ";" / "="
|
174
|
+
# x-www-form-urlencoded-delimiters = "&" / "+" / ";" / "="
|
175
|
+
r << sep if !first
|
176
|
+
first = false
|
177
|
+
k.each_byte {|byte|
|
178
|
+
ch = byte.chr
|
179
|
+
if %r{[^0-9A-Za-z\-\._~:/?@!\$'()*,]}n =~ ch
|
180
|
+
r << "%" << ch.unpack("H2")[0].upcase
|
181
|
+
else
|
182
|
+
r << ch
|
183
|
+
end
|
184
|
+
}
|
185
|
+
r << '='
|
186
|
+
v.each_byte {|byte|
|
187
|
+
ch = byte.chr
|
188
|
+
if %r{[^0-9A-Za-z\-\._~:/?@!\$'()*,]}n =~ ch
|
189
|
+
r << "%" << ch.unpack("H2")[0].upcase
|
190
|
+
else
|
191
|
+
r << ch
|
192
|
+
end
|
193
|
+
}
|
194
|
+
}
|
195
|
+
r
|
196
|
+
end
|
197
|
+
|
198
|
+
# :stopdoc:
|
199
|
+
HTML_TEXT_ESCAPE_HASH = {
|
200
|
+
'&' => '&',
|
201
|
+
'<' => '<',
|
202
|
+
'>' => '>',
|
203
|
+
}
|
204
|
+
# :startdoc:
|
205
|
+
|
206
|
+
# Escape.html_text escapes a string appropriate for HTML text using character references.
|
207
|
+
#
|
208
|
+
# It escapes 3 characters:
|
209
|
+
# * '&' to '&'
|
210
|
+
# * '<' to '<'
|
211
|
+
# * '>' to '>'
|
212
|
+
#
|
213
|
+
# Escape.html_text("abc") #=> "abc"
|
214
|
+
# Escape.html_text("a & b < c > d") #=> "a & b < c > d"
|
215
|
+
#
|
216
|
+
# This function is not appropriate for escaping HTML element attribute
|
217
|
+
# because quotes are not escaped.
|
218
|
+
def html_text(str)
|
219
|
+
str.gsub(/[&<>]/) {|ch| HTML_TEXT_ESCAPE_HASH[ch] }
|
220
|
+
end
|
221
|
+
|
222
|
+
# :stopdoc:
|
223
|
+
HTML_ATTR_ESCAPE_HASH = {
|
224
|
+
'&' => '&',
|
225
|
+
'<' => '<',
|
226
|
+
'>' => '>',
|
227
|
+
'"' => '"',
|
228
|
+
}
|
229
|
+
# :startdoc:
|
230
|
+
|
231
|
+
# Escape.html_attr encodes a string as a double-quoted HTML attribute using character references.
|
232
|
+
#
|
233
|
+
# Escape.html_attr("abc") #=> "\"abc\""
|
234
|
+
# Escape.html_attr("a&b") #=> "\"a&b\""
|
235
|
+
# Escape.html_attr("ab&<>\"c") #=> "\"ab&<>"c\""
|
236
|
+
# Escape.html_attr("a'c") #=> "\"a'c\""
|
237
|
+
#
|
238
|
+
# It escapes 4 characters:
|
239
|
+
# * '&' to '&'
|
240
|
+
# * '<' to '<'
|
241
|
+
# * '>' to '>'
|
242
|
+
# * '"' to '"'
|
243
|
+
#
|
244
|
+
def html_attr(str)
|
245
|
+
'"' + str.gsub(/[&<>"]/) {|ch| HTML_ATTR_ESCAPE_HASH[ch] } + '"'
|
246
|
+
end
|
247
|
+
end
|
@@ -0,0 +1,166 @@
|
|
1
|
+
2010-05-05 (1.4.3)
|
2
|
+
* Fixed some test assertions, from Ruby r27587 and r27590, patch by nobu.
|
3
|
+
* Fixed issue http://github.com/flori/json/issues/#issue/20 reported by
|
4
|
+
electronicwhisper@github. Thx!
|
5
|
+
2010-04-26 (1.4.2)
|
6
|
+
* Applied patch from naruse Yui NARUSE <naruse@airemix.com> to make building with
|
7
|
+
Microsoft Visual C possible again.
|
8
|
+
* Applied patch from devrandom <c1.github@niftybox.net> in order to allow building of
|
9
|
+
json_pure if extensiontask is not present.
|
10
|
+
* Thanks to Dustin Schneider <dustin@stocktwits.com>, who reported a memory
|
11
|
+
leak, which is fixed in this release.
|
12
|
+
* Applied 993f261ccb8f911d2ae57e9db48ec7acd0187283 patch from josh@github.
|
13
|
+
2010-04-25 (1.4.1)
|
14
|
+
* Fix for a bug reported by Dan DeLeo <dan@kallistec.com>, caused by T_FIXNUM
|
15
|
+
being different on 32bit/64bit architectures.
|
16
|
+
2010-04-23 (1.4.0)
|
17
|
+
* Major speed improvements and building with simplified
|
18
|
+
directory/file-structure.
|
19
|
+
* Extension should at least be comapatible with MRI, YARV and Rubinius.
|
20
|
+
2010-04-07 (1.2.4)
|
21
|
+
* Triger const_missing callback to make Rails' dynamic class loading work.
|
22
|
+
2010-03-11 (1.2.3)
|
23
|
+
* Added a State#[] method which returns an attribute's value in order to
|
24
|
+
increase duck type compatibility to Hash.
|
25
|
+
2010-02-27 (1.2.2)
|
26
|
+
* Made some changes to make the building of the parser/generator compatible
|
27
|
+
to Rubinius.
|
28
|
+
2009-11-25 (1.2.1)
|
29
|
+
* Added :symbolize_names option to Parser, which returns symbols instead of
|
30
|
+
strings in object names/keys.
|
31
|
+
2009-10-01 (1.2.0)
|
32
|
+
* fast_generate now raises an exeception for nan and infinite floats.
|
33
|
+
* On Ruby 1.8 json supports parsing of UTF-8, UTF-16BE, UTF-16LE, UTF-32BE,
|
34
|
+
and UTF-32LE JSON documents now. Under Ruby 1.9 the M17n conversion
|
35
|
+
functions are used to convert from all supported encodings. ASCII-8BIT
|
36
|
+
encoded strings are handled like all strings under Ruby 1.8 were.
|
37
|
+
* Better documentation
|
38
|
+
2009-08-23 (1.1.9)
|
39
|
+
* Added forgotten main doc file extra_rdoc_files.
|
40
|
+
2009-08-23 (1.1.8)
|
41
|
+
* Applied a patch by OZAWA Sakuro <sakuro@2238club.org> to make json/pure
|
42
|
+
work in environments that don't provide iconv.
|
43
|
+
* Applied patch by okkez_ in order to fix Ruby Bug #1768:
|
44
|
+
http://redmine.ruby-lang.org/issues/show/1768.
|
45
|
+
* Finally got around to avoid the rather paranoid escaping of ?/ characters
|
46
|
+
in the generator's output. The parsers aren't affected by this change.
|
47
|
+
Thanks to Rich Apodaca <rapodaca@metamolecular.com> for the suggestion.
|
48
|
+
2009-06-29 (1.1.7)
|
49
|
+
* Security Fix for JSON::Pure::Parser. A specially designed string could
|
50
|
+
cause catastrophic backtracking in one of the parser's regular expressions
|
51
|
+
in earlier 1.1.x versions. JSON::Ext::Parser isn't affected by this issue.
|
52
|
+
Thanks to Bartosz Blimke <bartosz@new-bamboo.co.uk> for reporting this
|
53
|
+
problem.
|
54
|
+
* This release also uses a less strict ruby version requirement for the
|
55
|
+
creation of the mswin32 native gem.
|
56
|
+
2009-05-10 (1.1.6)
|
57
|
+
* No changes. І tested native linux gems in the last release and they don't
|
58
|
+
play well with different ruby versions other than the one the gem was built
|
59
|
+
with. This release is just to bump the version number in order to skip the
|
60
|
+
native gem on rubyforge.
|
61
|
+
2009-05-10 (1.1.5)
|
62
|
+
* Started to build gems with rake-compiler gem.
|
63
|
+
* Applied patch object/array class patch from Brian Candler
|
64
|
+
<B.Candler@pobox.com> and fixes.
|
65
|
+
2009-04-01 (1.1.4)
|
66
|
+
* Fixed a bug in the creation of serialized generic rails objects reported by
|
67
|
+
Friedrich Graeter <graeter@hydrixos.org>.
|
68
|
+
* Deleted tests/runner.rb, we're using testrb instead.
|
69
|
+
* Editor supports Infinity in numbers now.
|
70
|
+
* Made some changes in order to get the library to compile/run under Ruby
|
71
|
+
1.9.
|
72
|
+
* Improved speed of the code path for the fast_generate method in the pure
|
73
|
+
variant.
|
74
|
+
2008-07-10 (1.1.3)
|
75
|
+
* Wesley Beary <monki@geemus.com> reported a bug in json/add/core's DateTime
|
76
|
+
handling: If the nominator and denominator of the offset were divisible by
|
77
|
+
each other Ruby's Rational#to_s returns them as an integer not a fraction
|
78
|
+
with '/'. This caused a ZeroDivisionError during parsing.
|
79
|
+
* Use Date#start and DateTime#start instead of sg method, while
|
80
|
+
remaining backwards compatible.
|
81
|
+
* Supports ragel >= 6.0 now.
|
82
|
+
* Corrected some tests.
|
83
|
+
* Some minor changes.
|
84
|
+
2007-11-27 (1.1.2)
|
85
|
+
* Remember default dir (last used directory) in editor.
|
86
|
+
* JSON::Editor.edit method added, the editor can now receive json texts from
|
87
|
+
the clipboard via C-v.
|
88
|
+
* Load json texts from an URL pasted via middle button press.
|
89
|
+
* Added :create_additions option to Parser. This makes it possible to disable
|
90
|
+
the creation of additions by force, in order to treat json texts as data
|
91
|
+
while having additions loaded.
|
92
|
+
* Jacob Maine <jmaine@blurb.com> reported, that JSON(:foo) outputs a JSON
|
93
|
+
object if the rails addition is enabled, which is wrong. It now outputs a
|
94
|
+
JSON string "foo" instead, like suggested by Jacob Maine.
|
95
|
+
* Discovered a bug in the Ruby Bugs Tracker on rubyforge, that was reported
|
96
|
+
by John Evans lgastako@gmail.com. He could produce a crash in the JSON
|
97
|
+
generator by returning something other than a String instance from a
|
98
|
+
to_json method. I now guard against this by doing a rather crude type
|
99
|
+
check, which raises an exception instead of crashing.
|
100
|
+
2007-07-06 (1.1.1)
|
101
|
+
* Yui NARUSE <naruse@airemix.com> sent some patches to fix tests for Ruby
|
102
|
+
1.9. I applied them and adapted some of them a bit to run both on 1.8 and
|
103
|
+
1.9.
|
104
|
+
* Introduced a JSON.parse! method without depth checking for people who like
|
105
|
+
danger.
|
106
|
+
* Made generate and pretty_generate methods configurable by an options hash.
|
107
|
+
* Added :allow_nan option to parser and generator in order to handle NaN,
|
108
|
+
Infinity, and -Infinity correctly - if requested. Floats, which aren't numbers,
|
109
|
+
aren't valid JSON according to RFC4627, so by default an exception will be
|
110
|
+
raised if any of these symbols are encountered. Thanks to Andrea Censi
|
111
|
+
<andrea.censi@dis.uniroma1.it> for his hint about this.
|
112
|
+
* Fixed some more tests for Ruby 1.9.
|
113
|
+
* Implemented dump/load interface of Marshal as suggested in ruby-core:11405
|
114
|
+
by murphy <murphy@rubychan.de>.
|
115
|
+
* Implemented the max_nesting feature for generate methods, too.
|
116
|
+
* Added some implementations for ruby core's custom objects for
|
117
|
+
serialisation/deserialisation purposes.
|
118
|
+
2007-05-21 (1.1.0)
|
119
|
+
* Implemented max_nesting feature for parser to avoid stack overflows for
|
120
|
+
data from untrusted sources. If you trust the source, you can disable it
|
121
|
+
with the option max_nesting => false.
|
122
|
+
* Piers Cawley <pdcawley@bofh.org.uk> reported a bug, that not every
|
123
|
+
character can be escaped by ?\ as required by RFC4627. There's a
|
124
|
+
contradiction between David Crockford's JSON checker test vectors (in
|
125
|
+
tests/fixtures) and RFC4627, though. I decided to stick to the RFC, because
|
126
|
+
the JSON checker seems to be a bit older than the RFC.
|
127
|
+
* Extended license to Ruby License, which includes the GPL.
|
128
|
+
* Added keyboard shortcuts, and 'Open location' menu item to edit_json.rb.
|
129
|
+
2007-05-09 (1.0.4)
|
130
|
+
* Applied a patch from Yui NARUSE <naruse@airemix.com> to make JSON compile
|
131
|
+
under Ruby 1.9. Thank you very much for mailing it to me!
|
132
|
+
* Made binary variants of JSON fail early, instead of falling back to the
|
133
|
+
pure version. This should avoid overshadowing of eventual problems while
|
134
|
+
loading of the binary.
|
135
|
+
2007-03-24 (1.0.3)
|
136
|
+
* Improved performance of pure variant a bit.
|
137
|
+
* The ext variant of this release supports the mswin32 platform. Ugh!
|
138
|
+
2007-03-24 (1.0.2)
|
139
|
+
* Ext Parser didn't parse 0e0 correctly into 0.0: Fixed!
|
140
|
+
2007-03-24 (1.0.1)
|
141
|
+
* Forgot some object files in the build dir. I really like that - not!
|
142
|
+
2007-03-24 (1.0.0)
|
143
|
+
* Added C implementations for the JSON generator and a ragel based JSON
|
144
|
+
parser in C.
|
145
|
+
* Much more tests, especially fixtures from json.org.
|
146
|
+
* Further improved conformance to RFC4627.
|
147
|
+
2007-02-09 (0.4.3)
|
148
|
+
* Conform more to RFC4627 for JSON: This means JSON strings
|
149
|
+
now always must contain exactly one object "{ ... }" or array "[ ... ]" in
|
150
|
+
order to be parsed without raising an exception. The definition of what
|
151
|
+
constitutes a whitespace is narrower in JSON than in Ruby ([ \t\r\n]), and
|
152
|
+
there are differences in floats and integers (no octals or hexadecimals) as
|
153
|
+
well.
|
154
|
+
* Added aliases generate and pretty_generate of unparse and pretty_unparse.
|
155
|
+
* Fixed a test case.
|
156
|
+
* Catch an Iconv::InvalidEncoding exception, that seems to occur on some Sun
|
157
|
+
boxes with SunOS 5.8, if iconv doesn't support utf16 conversions. This was
|
158
|
+
reported by Andrew R Jackson <andrewj@bcm.tmc.edu>, thanks a bunch!
|
159
|
+
2006-08-25 (0.4.2)
|
160
|
+
* Fixed a bug in handling solidi (/-characters), that was reported by
|
161
|
+
Kevin Gilpin <kevin.gilpin@alum.mit.edu>.
|
162
|
+
2006-02-06 (0.4.1)
|
163
|
+
* Fixed a bug related to escaping with backslashes. Thanks for the report go
|
164
|
+
to Florian Munz <surf@theflow.de>.
|
165
|
+
2005-09-23 (0.4.0)
|
166
|
+
* Initial Rubyforge Version
|
@@ -0,0 +1,58 @@
|
|
1
|
+
Ruby is copyrighted free software by Yukihiro Matsumoto <matz@netlab.co.jp>.
|
2
|
+
You can redistribute it and/or modify it under either the terms of the GPL
|
3
|
+
(see GPL file), or the conditions below:
|
4
|
+
|
5
|
+
1. You may make and give away verbatim copies of the source form of the
|
6
|
+
software without restriction, provided that you duplicate all of the
|
7
|
+
original copyright notices and associated disclaimers.
|
8
|
+
|
9
|
+
2. You may modify your copy of the software in any way, provided that
|
10
|
+
you do at least ONE of the following:
|
11
|
+
|
12
|
+
a) place your modifications in the Public Domain or otherwise
|
13
|
+
make them Freely Available, such as by posting said
|
14
|
+
modifications to Usenet or an equivalent medium, or by allowing
|
15
|
+
the author to include your modifications in the software.
|
16
|
+
|
17
|
+
b) use the modified software only within your corporation or
|
18
|
+
organization.
|
19
|
+
|
20
|
+
c) rename any non-standard executables so the names do not conflict
|
21
|
+
with standard executables, which must also be provided.
|
22
|
+
|
23
|
+
d) make other distribution arrangements with the author.
|
24
|
+
|
25
|
+
3. You may distribute the software in object code or executable
|
26
|
+
form, provided that you do at least ONE of the following:
|
27
|
+
|
28
|
+
a) distribute the executables and library files of the software,
|
29
|
+
together with instructions (in the manual page or equivalent)
|
30
|
+
on where to get the original distribution.
|
31
|
+
|
32
|
+
b) accompany the distribution with the machine-readable source of
|
33
|
+
the software.
|
34
|
+
|
35
|
+
c) give non-standard executables non-standard names, with
|
36
|
+
instructions on where to get the original software distribution.
|
37
|
+
|
38
|
+
d) make other distribution arrangements with the author.
|
39
|
+
|
40
|
+
4. You may modify and include the part of the software into any other
|
41
|
+
software (possibly commercial). But some files in the distribution
|
42
|
+
are not written by the author, so that they are not under this terms.
|
43
|
+
|
44
|
+
They are gc.c(partly), utils.c(partly), regex.[ch], st.[ch] and some
|
45
|
+
files under the ./missing directory. See each file for the copying
|
46
|
+
condition.
|
47
|
+
|
48
|
+
5. The scripts and library files supplied as input to or produced as
|
49
|
+
output from the software do not automatically fall under the
|
50
|
+
copyright of the software, but belong to whomever generated them,
|
51
|
+
and may be sold commercially, and may be aggregated with this
|
52
|
+
software.
|
53
|
+
|
54
|
+
6. THIS SOFTWARE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR
|
55
|
+
IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
|
56
|
+
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
57
|
+
PURPOSE.
|
58
|
+
|