nano-pure-box 0.0.1

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.
Files changed (36) hide show
  1. checksums.yaml +7 -0
  2. data/nano-pure-box.gemspec +12 -0
  3. data/redcarpet-3.6.1/CHANGELOG.md +487 -0
  4. data/redcarpet-3.6.1/CONTRIBUTING.md +33 -0
  5. data/redcarpet-3.6.1/COPYING +20 -0
  6. data/redcarpet-3.6.1/Gemfile +9 -0
  7. data/redcarpet-3.6.1/README.markdown +405 -0
  8. data/redcarpet-3.6.1/Rakefile +60 -0
  9. data/redcarpet-3.6.1/bin/redcarpet +7 -0
  10. data/redcarpet-3.6.1/ext/redcarpet/autolink.c +308 -0
  11. data/redcarpet-3.6.1/ext/redcarpet/autolink.h +55 -0
  12. data/redcarpet-3.6.1/ext/redcarpet/buffer.c +203 -0
  13. data/redcarpet-3.6.1/ext/redcarpet/buffer.h +88 -0
  14. data/redcarpet-3.6.1/ext/redcarpet/extconf.rb +6 -0
  15. data/redcarpet-3.6.1/ext/redcarpet/houdini.h +51 -0
  16. data/redcarpet-3.6.1/ext/redcarpet/houdini_href_e.c +124 -0
  17. data/redcarpet-3.6.1/ext/redcarpet/houdini_html_e.c +104 -0
  18. data/redcarpet-3.6.1/ext/redcarpet/html.c +869 -0
  19. data/redcarpet-3.6.1/ext/redcarpet/html.h +83 -0
  20. data/redcarpet-3.6.1/ext/redcarpet/html_block_names.txt +44 -0
  21. data/redcarpet-3.6.1/ext/redcarpet/html_blocks.h +222 -0
  22. data/redcarpet-3.6.1/ext/redcarpet/html_smartypants.c +472 -0
  23. data/redcarpet-3.6.1/ext/redcarpet/markdown.c +2946 -0
  24. data/redcarpet-3.6.1/ext/redcarpet/markdown.h +143 -0
  25. data/redcarpet-3.6.1/ext/redcarpet/rc_markdown.c +194 -0
  26. data/redcarpet-3.6.1/ext/redcarpet/rc_render.c +601 -0
  27. data/redcarpet-3.6.1/ext/redcarpet/redcarpet.h +54 -0
  28. data/redcarpet-3.6.1/ext/redcarpet/stack.c +84 -0
  29. data/redcarpet-3.6.1/ext/redcarpet/stack.h +48 -0
  30. data/redcarpet-3.6.1/lib/redcarpet/cli.rb +86 -0
  31. data/redcarpet-3.6.1/lib/redcarpet/compat.rb +71 -0
  32. data/redcarpet-3.6.1/lib/redcarpet/render_man.rb +65 -0
  33. data/redcarpet-3.6.1/lib/redcarpet/render_strip.rb +60 -0
  34. data/redcarpet-3.6.1/lib/redcarpet.rb +92 -0
  35. data/redcarpet-3.6.1/redcarpet.gemspec +59 -0
  36. metadata +75 -0
@@ -0,0 +1,124 @@
1
+ /*
2
+ * Copyright (c) 2015, Vicent Marti
3
+ *
4
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
5
+ * of this software and associated documentation files (the "Software"), to deal
6
+ * in the Software without restriction, including without limitation the rights
7
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8
+ * copies of the Software, and to permit persons to whom the Software is
9
+ * furnished to do so, subject to the following conditions:
10
+ *
11
+ * The above copyright notice and this permission notice shall be included in
12
+ * all copies or substantial portions of the Software.
13
+ *
14
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
20
+ * THE SOFTWARE.
21
+ */
22
+
23
+ #include <assert.h>
24
+ #include <stdio.h>
25
+ #include <string.h>
26
+
27
+ #include "houdini.h"
28
+
29
+ #define ESCAPE_GROW_FACTOR(x) (((x) * 12) / 10)
30
+
31
+ /*
32
+ * The following characters will not be escaped:
33
+ *
34
+ * -_.+!*'(),%#@?=;:/,+&$ alphanum
35
+ *
36
+ * Note that this character set is the addition of:
37
+ *
38
+ * - The characters which are safe to be in an URL
39
+ * - The characters which are *not* safe to be in
40
+ * an URL because they are RESERVED characters.
41
+ *
42
+ * We asume (lazily) that any RESERVED char that
43
+ * appears inside an URL is actually meant to
44
+ * have its native function (i.e. as an URL
45
+ * component/separator) and hence needs no escaping.
46
+ *
47
+ * There is one exception: the ' (single quote)
48
+ * character does not appear in the table.
49
+ * It is meant to appear in the URL as components,
50
+ * however it require special HTML-entity escaping
51
+ * to generate valid HTML markup.
52
+ *
53
+ * All other characters will be escaped to %XX.
54
+ *
55
+ */
56
+ static const char HREF_SAFE[] = {
57
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
58
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
59
+ 0, 1, 0, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1,
60
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 0, 1,
61
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
62
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 1,
63
+ 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
64
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0,
65
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
66
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
67
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
68
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
69
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
70
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
71
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
72
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
73
+ };
74
+
75
+ void
76
+ houdini_escape_href(struct buf *ob, const uint8_t *src, size_t size)
77
+ {
78
+ static const char hex_chars[] = "0123456789ABCDEF";
79
+ size_t i = 0, org;
80
+ char hex_str[3];
81
+
82
+ bufgrow(ob, ESCAPE_GROW_FACTOR(size));
83
+ hex_str[0] = '%';
84
+
85
+ while (i < size) {
86
+ org = i;
87
+ while (i < size && HREF_SAFE[src[i]] != 0)
88
+ i++;
89
+
90
+ if (i > org)
91
+ bufput(ob, src + org, i - org);
92
+
93
+ /* escaping */
94
+ if (i >= size)
95
+ break;
96
+
97
+ switch (src[i]) {
98
+ /* the single quote is a valid URL character
99
+ * according to the standard; it needs HTML
100
+ * entity escaping too */
101
+ case '\'':
102
+ BUFPUTSL(ob, "&#x27;");
103
+ break;
104
+
105
+ /* the space can be escaped to %20 or a plus
106
+ * sign. we're going with the generic escape
107
+ * for now. the plus thing is more commonly seen
108
+ * when building GET strings */
109
+ #if 0
110
+ case ' ':
111
+ bufputc(ob, '+');
112
+ break;
113
+ #endif
114
+
115
+ /* every other character goes with a %XX escaping */
116
+ default:
117
+ hex_str[1] = hex_chars[(src[i] >> 4) & 0xF];
118
+ hex_str[2] = hex_chars[src[i] & 0xF];
119
+ bufput(ob, hex_str, 3);
120
+ }
121
+
122
+ i++;
123
+ }
124
+ }
@@ -0,0 +1,104 @@
1
+ /*
2
+ * Copyright (c) 2015, Vicent Marti
3
+ *
4
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
5
+ * of this software and associated documentation files (the "Software"), to deal
6
+ * in the Software without restriction, including without limitation the rights
7
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8
+ * copies of the Software, and to permit persons to whom the Software is
9
+ * furnished to do so, subject to the following conditions:
10
+ *
11
+ * The above copyright notice and this permission notice shall be included in
12
+ * all copies or substantial portions of the Software.
13
+ *
14
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
20
+ * THE SOFTWARE.
21
+ */
22
+
23
+ #include <assert.h>
24
+ #include <stdio.h>
25
+ #include <string.h>
26
+
27
+ #include "houdini.h"
28
+
29
+ #define ESCAPE_GROW_FACTOR(x) (((x) * 12) / 10) /* this is very scientific, yes */
30
+
31
+ /**
32
+ * According to the OWASP rules:
33
+ *
34
+ * & --> &amp;
35
+ * < --> &lt;
36
+ * > --> &gt;
37
+ * " --> &quot;
38
+ * ' --> &#x27; &apos; is not recommended
39
+ * / --> &#x2F; forward slash is included as it helps end an HTML entity
40
+ *
41
+ */
42
+ static const char HTML_ESCAPE_TABLE[] = {
43
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
44
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
45
+ 0, 0, 1, 0, 0, 0, 2, 3, 0, 0, 0, 0, 0, 0, 0, 4,
46
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 5, 0, 6, 0,
47
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
48
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
49
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
50
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
51
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
52
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
53
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
54
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
55
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
56
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
57
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
58
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
59
+ };
60
+
61
+ static const char *HTML_ESCAPES[] = {
62
+ "",
63
+ "&quot;",
64
+ "&amp;",
65
+ "&#39;",
66
+ "&#47;",
67
+ "&lt;",
68
+ "&gt;"
69
+ };
70
+
71
+ void
72
+ houdini_escape_html0(struct buf *ob, const uint8_t *src, size_t size, int secure)
73
+ {
74
+ size_t i = 0, org, esc = 0;
75
+
76
+ bufgrow(ob, ESCAPE_GROW_FACTOR(size));
77
+
78
+ while (i < size) {
79
+ org = i;
80
+ while (i < size && (esc = HTML_ESCAPE_TABLE[src[i]]) == 0)
81
+ i++;
82
+
83
+ if (i > org)
84
+ bufput(ob, src + org, i - org);
85
+
86
+ /* escaping */
87
+ if (i >= size)
88
+ break;
89
+
90
+ /* The forward slash is only escaped in secure mode */
91
+ if (src[i] == '/' && !secure)
92
+ bufputc(ob, '/');
93
+ else
94
+ bufputs(ob, HTML_ESCAPES[esc]);
95
+
96
+ i++;
97
+ }
98
+ }
99
+
100
+ void
101
+ houdini_escape_html(struct buf *ob, const uint8_t *src, size_t size)
102
+ {
103
+ houdini_escape_html0(ob, src, size, 1);
104
+ }