closure 1.4.2 → 1.4.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -38,6 +38,11 @@
38
38
  goog.provide('soy');
39
39
  goog.provide('soy.StringBuilder');
40
40
  goog.provide('soy.esc');
41
+ goog.provide('soydata');
42
+ goog.provide('soydata.SanitizedHtml');
43
+ goog.provide('soydata.SanitizedHtmlAttribute');
44
+ goog.provide('soydata.SanitizedJsStrChars');
45
+ goog.provide('soydata.SanitizedUri');
41
46
 
42
47
  goog.require('goog.asserts');
43
48
  goog.require('goog.dom.DomHelper');
@@ -47,7 +52,6 @@ goog.require('goog.i18n.bidi');
47
52
  goog.require('goog.soy');
48
53
  goog.require('goog.string');
49
54
  goog.require('goog.string.StringBuffer');
50
- goog.require('soydata');
51
55
 
52
56
 
53
57
  // -----------------------------------------------------------------------------
@@ -66,6 +70,140 @@ goog.require('soydata');
66
70
  soy.StringBuilder = goog.string.StringBuffer;
67
71
 
68
72
 
73
+ // -----------------------------------------------------------------------------
74
+ // soydata: Defines typed strings, e.g. an HTML string {@code "a<b>c"} is
75
+ // semantically distinct from the plain text string {@code "a<b>c"} and smart
76
+ // templates can take that distinction into account.
77
+
78
+ /**
79
+ * A type of textual content.
80
+ * @enum {number}
81
+ */
82
+ soydata.SanitizedContentKind = {
83
+
84
+ /**
85
+ * A snippet of HTML that does not start or end inside a tag, comment, entity,
86
+ * or DOCTYPE; and that does not contain any executable code
87
+ * (JS, {@code <object>}s, etc.) from a different trust domain.
88
+ */
89
+ HTML: 0,
90
+
91
+ /**
92
+ * A sequence of code units that can appear between quotes (either kind) in a
93
+ * JS program without causing a parse error, and without causing any side
94
+ * effects.
95
+ * <p>
96
+ * The content should not contain unescaped quotes, newlines, or anything else
97
+ * that would cause parsing to fail or to cause a JS parser to finish the
98
+ * string its parsing inside the content.
99
+ * <p>
100
+ * The content must also not end inside an escape sequence ; no partial octal
101
+ * escape sequences or odd number of '{@code \}'s at the end.
102
+ */
103
+ JS_STR_CHARS: 1,
104
+
105
+ /** A properly encoded portion of a URI. */
106
+ URI: 2,
107
+
108
+ /** An attribute name and value such as {@code dir="ltr"}. */
109
+ HTML_ATTRIBUTE: 3
110
+ };
111
+
112
+
113
+ /**
114
+ * A string-like object that carries a content-type.
115
+ * @param {string} content
116
+ * @constructor
117
+ * @private
118
+ */
119
+ soydata.SanitizedContent = function(content) {
120
+ /**
121
+ * The textual content.
122
+ * @type {string}
123
+ */
124
+ this.content = content;
125
+ };
126
+
127
+ /** @type {soydata.SanitizedContentKind} */
128
+ soydata.SanitizedContent.prototype.contentKind;
129
+
130
+ /** @override */
131
+ soydata.SanitizedContent.prototype.toString = function() {
132
+ return this.content;
133
+ };
134
+
135
+
136
+ /**
137
+ * Content of type {@link soydata.SanitizedContentKind.HTML}.
138
+ * @param {string} content A string of HTML that can safely be embedded in
139
+ * a PCDATA context in your app. If you would be surprised to find that an
140
+ * HTML sanitizer produced {@code s} (e.g. it runs code or fetches bad URLs)
141
+ * and you wouldn't write a template that produces {@code s} on security or
142
+ * privacy grounds, then don't pass {@code s} here.
143
+ * @constructor
144
+ * @extends {soydata.SanitizedContent}
145
+ */
146
+ soydata.SanitizedHtml = function(content) {
147
+ soydata.SanitizedContent.call(this, content);
148
+ };
149
+ goog.inherits(soydata.SanitizedHtml, soydata.SanitizedContent);
150
+
151
+ /** @override */
152
+ soydata.SanitizedHtml.prototype.contentKind = soydata.SanitizedContentKind.HTML;
153
+
154
+
155
+ /**
156
+ * Content of type {@link soydata.SanitizedContentKind.JS_STR_CHARS}.
157
+ * @param {string} content A string of JS that when evaled, produces a
158
+ * value that does not depend on any sensitive data and has no side effects
159
+ * <b>OR</b> a string of JS that does not reference any variables or have
160
+ * any side effects not known statically to the app authors.
161
+ * @constructor
162
+ * @extends {soydata.SanitizedContent}
163
+ */
164
+ soydata.SanitizedJsStrChars = function(content) {
165
+ soydata.SanitizedContent.call(this, content);
166
+ };
167
+ goog.inherits(soydata.SanitizedJsStrChars, soydata.SanitizedContent);
168
+
169
+ /** @override */
170
+ soydata.SanitizedJsStrChars.prototype.contentKind =
171
+ soydata.SanitizedContentKind.JS_STR_CHARS;
172
+
173
+
174
+ /**
175
+ * Content of type {@link soydata.SanitizedContentKind.URI}.
176
+ * @param {string} content A chunk of URI that the caller knows is safe to
177
+ * emit in a template.
178
+ * @constructor
179
+ * @extends {soydata.SanitizedContent}
180
+ */
181
+ soydata.SanitizedUri = function(content) {
182
+ soydata.SanitizedContent.call(this, content);
183
+ };
184
+ goog.inherits(soydata.SanitizedUri, soydata.SanitizedContent);
185
+
186
+ /** @override */
187
+ soydata.SanitizedUri.prototype.contentKind = soydata.SanitizedContentKind.URI;
188
+
189
+
190
+ /**
191
+ * Content of type {@link soydata.SanitizedContentKind.HTML_ATTRIBUTE}.
192
+ * @param {string} content An attribute name and value, such as
193
+ * {@code dir="ltr"}.
194
+ * @constructor
195
+ * @extends {soydata.SanitizedContent}
196
+ */
197
+ soydata.SanitizedHtmlAttribute = function(content) {
198
+ soydata.SanitizedContent.call(this, content);
199
+ };
200
+ goog.inherits(soydata.SanitizedHtmlAttribute, soydata.SanitizedContent);
201
+
202
+ /** @override */
203
+ soydata.SanitizedHtmlAttribute.prototype.contentKind =
204
+ soydata.SanitizedContentKind.HTML_ATTRIBUTE;
205
+
206
+
69
207
  // -----------------------------------------------------------------------------
70
208
  // Public utilities.
71
209
 
@@ -280,42 +418,6 @@ soy.$$EMPTY_TEMPLATE_FN_ = function(opt_data, opt_sb, opt_ijData) {
280
418
  };
281
419
 
282
420
 
283
- /**
284
- * Used for temporary fix. See GenJsCodeVisitor.java.
285
- * TODO: Remove when i18n plurals team provides a better # processing option.
286
- * @param {string} str The string to escape.
287
- * @return {string} The escaped string.
288
- */
289
- soy.$$tempHashEscape = function(str) {
290
- return str.replace(soy.$$HASH_RE_, '__HashLit__');
291
- };
292
-
293
- /**
294
- * Used by soy.$$tempHashEscape().
295
- * @type {RegExp}
296
- * @private
297
- */
298
- soy.$$HASH_RE_ = /#/g;
299
-
300
-
301
- /**
302
- * Used for temporary fix. See GenJsCodeVisitor.java.
303
- * TODO: Remove when i18n plurals team provides a better # processing option.
304
- * @param {string} str The string to unescape.
305
- * @return {string} The unescaped string.
306
- */
307
- soy.$$tempHashUnescape = function(str) {
308
- return str.replace(soy.$$HASH_ESCAPED_RE_, '#');
309
- };
310
-
311
- /**
312
- * Used by soy.$$tempHashUnescape().
313
- * @type {RegExp}
314
- * @private
315
- */
316
- soy.$$HASH_ESCAPED_RE_ = /__HashLit__/g;
317
-
318
-
319
421
  // -----------------------------------------------------------------------------
320
422
  // Escape/filter/normalize.
321
423
 
@@ -740,30 +842,6 @@ soy.$$getBidiFormatterInstance_ = function(bidiGlobalDir) {
740
842
  };
741
843
 
742
844
 
743
- /**
744
- * Returns the leading horizontal edge, i.e. "left" or "right", depending on
745
- * bidiGlobalDir.
746
- * @param {number} bidiGlobalDir The global directionality context: 1 if ltr, -1
747
- * if rtl, 0 if unknown.
748
- * @return {string} "right" for RTL context and "left" otherwise.
749
- */
750
- soy.$$bidiStartEdge = function(bidiGlobalDir) {
751
- return soy.$$getBidiFormatterInstance_(bidiGlobalDir).startEdge();
752
- };
753
-
754
-
755
- /**
756
- * Returns the trailing horizontal edge, i.e. "right" or "left", depending on
757
- * bidiGlobalDir.
758
- * @param {number} bidiGlobalDir The global directionality context: 1 if ltr, -1
759
- * if rtl, 0 if unknown.
760
- * @return {string} "left" for RTL context and "right" otherwise.
761
- */
762
- soy.$$bidiEndEdge = function(bidiGlobalDir) {
763
- return soy.$$getBidiFormatterInstance_(bidiGlobalDir).endEdge();
764
- };
765
-
766
-
767
845
  /**
768
846
  * Estimate the overall directionality of text. If opt_isHtml, makes sure to
769
847
  * ignore the LTR nature of the mark-up and escapes in text, making the logic
@@ -802,19 +880,6 @@ soy.$$bidiDirAttr = function(bidiGlobalDir, text, opt_isHtml) {
802
880
  };
803
881
 
804
882
 
805
- /**
806
- * Returns a Unicode BiDi mark matching bidiGlobalDir (LRM or RLM), or an empty
807
- * string if bidiGlobalDir is 0 (unknown).
808
- * @param {number} bidiGlobalDir The global directionality context: 1 if ltr, -1
809
- * if rtl, 0 if unknown.
810
- * @return {string} A Unicode bidi mark matching bidiGlobalDir, or the empty
811
- * string when bidiGlobalDir is 0 (unknown).
812
- */
813
- soy.$$bidiMark = function(bidiGlobalDir) {
814
- return soy.$$getBidiFormatterInstance_(bidiGlobalDir).mark();
815
- };
816
-
817
-
818
883
  /**
819
884
  * Returns a Unicode BiDi mark matching bidiGlobalDir (LRM or RLM) if the
820
885
  * directionality or the exit directionality of text are opposite to
@@ -228,16 +228,21 @@ class Closure
228
228
  protected
229
229
 
230
230
 
231
- # Namespace recursion with circular stop on the filename
232
- def calcdeps(ns, namespace, filenames, prev = nil)
231
+ # Namespace recursion with two-way circular stop
232
+ def calcdeps(ns, namespace, filenames, prev = [])
233
233
  unless source = ns[namespace]
234
- msg = "#{prev[:filename]}: " rescue ''
234
+ msg = "#{prev.last[:filename]}: " rescue ''
235
235
  msg += "Namespace #{namespace.dump} not found."
236
236
  raise msg
237
237
  end
238
- return if source == prev or filenames.include? source[:filename]
238
+ if prev.include? source
239
+ return
240
+ else
241
+ prev.push source
242
+ end
243
+ return if filenames.include?(source[:filename])
239
244
  source[:require].each do |required|
240
- calcdeps ns, required, filenames, source
245
+ calcdeps ns, required, filenames, prev
241
246
  end
242
247
  filenames.push source[:filename]
243
248
  end
@@ -14,5 +14,5 @@
14
14
 
15
15
 
16
16
  class Closure
17
- VERSION = "1.4.2"
17
+ VERSION = "1.4.3"
18
18
  end
data/lib/closure.rb CHANGED
@@ -61,6 +61,7 @@ class Closure
61
61
  raise "Unknown built-in: #{directory}" unless dir
62
62
  directory = dir
63
63
  end
64
+ raise Errno::ENOENT, File.expand_path(directory, Dir.pwd) unless File.directory? directory
64
65
  sources.add directory, path
65
66
  end
66
67
 
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: closure
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 1.4.2
5
+ version: 1.4.3
6
6
  platform: ruby
7
7
  authors:
8
8
  - David Turnbull
@@ -10,7 +10,7 @@ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
12
 
13
- date: 2011-10-25 00:00:00 Z
13
+ date: 2011-12-01 00:00:00 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: rack
@@ -41,7 +41,6 @@ files:
41
41
  - closure-compiler/README
42
42
  - closure-templates/COPYING
43
43
  - closure-templates/README
44
- - closure-templates/soydata.js
45
44
  - closure-templates/SoyToJsSrcCompiler.jar
46
45
  - closure-templates/soyutils.js
47
46
  - closure-templates/soyutils_usegoog.js
@@ -138,7 +137,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
138
137
  requirements:
139
138
  - - ">="
140
139
  - !ruby/object:Gem::Version
141
- hash: 471027721912702129
140
+ hash: -3550757855017757460
142
141
  segments:
143
142
  - 0
144
143
  version: "0"
@@ -151,7 +150,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
151
150
  requirements: []
152
151
 
153
152
  rubyforge_project:
154
- rubygems_version: 1.8.6
153
+ rubygems_version: 1.8.10
155
154
  signing_key:
156
155
  specification_version: 3
157
156
  summary: Google Closure Compiler, Library, Script, and Templates.
@@ -1,163 +0,0 @@
1
- /*
2
- * Copyright 2010 Google Inc.
3
- *
4
- * Licensed under the Apache License, Version 2.0 (the "License");
5
- * you may not use this file except in compliance with the License.
6
- * You may obtain a copy of the License at
7
- *
8
- * http://www.apache.org/licenses/LICENSE-2.0
9
- *
10
- * Unless required by applicable law or agreed to in writing, software
11
- * distributed under the License is distributed on an "AS IS" BASIS,
12
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
- * See the License for the specific language governing permissions and
14
- * limitations under the License.
15
- */
16
-
17
-
18
- /**
19
- * @fileoverview
20
- * Defines typed strings, e.g. an HTML string {@code "a<b>c"} is
21
- * semantically distinct from the plain text string {@code "a<b>c"} and smart
22
- * templates can take that distinction into account.
23
- *
24
- * @author Mike Samuel
25
- */
26
-
27
-
28
- goog.provide('soydata');
29
- goog.provide('soydata.SanitizedHtml');
30
- goog.provide('soydata.SanitizedHtmlAttribute');
31
- goog.provide('soydata.SanitizedJsStrChars');
32
- goog.provide('soydata.SanitizedUri');
33
-
34
-
35
- /**
36
- * A type of textual content.
37
- * @enum
38
- */
39
- soydata.SanitizedContentKind = {
40
-
41
- /**
42
- * A snippet of HTML that does not start or end inside a tag, comment, entity,
43
- * or DOCTYPE; and that does not contain any executable code
44
- * (JS, {@code <object>}s, etc.) from a different trust domain.
45
- */
46
- HTML: 0,
47
-
48
- /**
49
- * A sequence of code units that can appear between quotes (either kind) in a
50
- * JS program without causing a parse error, and without causing any side
51
- * effects.
52
- * <p>
53
- * The content should not contain unescaped quotes, newlines, or anything else
54
- * that would cause parsing to fail or to cause a JS parser to finish the
55
- * string its parsing inside the content.
56
- * <p>
57
- * The content must also not end inside an escape sequence ; no partial octal
58
- * escape sequences or odd number of '{@code \}'s at the end.
59
- */
60
- JS_STR_CHARS: 1,
61
-
62
- /** A properly encoded portion of a URI. */
63
- URI: 2,
64
-
65
- /** An attribute name and value such as {@code dir="ltr"}. */
66
- HTML_ATTRIBUTE: 3
67
- };
68
-
69
-
70
- /**
71
- * A string-like object that carries a content-type.
72
- * @constructor
73
- * @private
74
- */
75
- soydata.SanitizedContent = function() {};
76
-
77
- /** The textual content. @type {string} */
78
- soydata.SanitizedContent.prototype.content;
79
-
80
- /** @type {soydata.SanitizedContentKind} */
81
- soydata.SanitizedContent.prototype.contentKind;
82
-
83
- /**
84
- * @return {string}
85
- */
86
- soydata.SanitizedContent.prototype.toString = function() {
87
- return this.content;
88
- };
89
-
90
-
91
- /**
92
- * Content of type {@link soydata.SanitizedContentKind.HTML}.
93
- * @constructor
94
- * @param {string!} content A string of HTML that can safely be embedded in
95
- * a PCDATA context in your app. If you would be surprised to find that an
96
- * HTML sanitizer produced {@code s} (e.g. it runs code or fetches bad URLs)
97
- * and you wouldn't write a template that produces {@code s} on security or
98
- * privacy grounds, then don't pass {@code s} here.
99
- */
100
- soydata.SanitizedHtml = function(content) {
101
- this.content = content;
102
- };
103
-
104
- /** @override */
105
- soydata.SanitizedHtml.prototype = new soydata.SanitizedContent();
106
-
107
- /** @override */
108
- soydata.SanitizedHtml.prototype.contentKind = soydata.SanitizedContentKind.HTML;
109
-
110
-
111
- /**
112
- * Content of type {@link soydata.SanitizedContentKind.JS_STR_CHARS}.
113
- * @constructor
114
- * @param {string!} content A string of JS that when evaled, produces a
115
- * value that does not depend on any sensitive data and has no side effects
116
- * <b>OR</b> a string of JS that does not reference any variables or have
117
- * any side effects not known statically to the app authors.
118
- */
119
- soydata.SanitizedJsStrChars = function(content) {
120
- this.content = content;
121
- };
122
-
123
- /** @override */
124
- soydata.SanitizedJsStrChars.prototype = new soydata.SanitizedContent();
125
-
126
- /** @override */
127
- soydata.SanitizedJsStrChars.prototype.contentKind =
128
- soydata.SanitizedContentKind.JS_STR_CHARS;
129
-
130
-
131
- /**
132
- * Content of type {@link soydata.SanitizedContentKind.URI}.
133
- * @constructor
134
- * @param {string!} content A chunk of URI that the caller knows is safe to
135
- * emit in a template.
136
- */
137
- soydata.SanitizedUri = function(content) {
138
- this.content = content;
139
- };
140
-
141
- /** @override */
142
- soydata.SanitizedUri.prototype = new soydata.SanitizedContent();
143
-
144
- /** @override */
145
- soydata.SanitizedUri.prototype.contentKind = soydata.SanitizedContentKind.URI;
146
-
147
-
148
- /**
149
- * Content of type {@link soydata.SanitizedContentKind.HTML_ATTRIBUTE}.
150
- * @constructor
151
- * @param {string!} content An attribute name and value, such as
152
- * {@code dir="ltr"}..
153
- */
154
- soydata.SanitizedHtmlAttribute = function(content) {
155
- this.content = content;
156
- };
157
-
158
- /** @override */
159
- soydata.SanitizedHtmlAttribute.prototype = new soydata.SanitizedContent();
160
-
161
- /** @override */
162
- soydata.SanitizedHtmlAttribute.prototype.contentKind =
163
- soydata.SanitizedContentKind.HTML_ATTRIBUTE;