piko-fast-lib 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.
- checksums.yaml +7 -0
- data/piko-fast-lib.gemspec +11 -0
- data/redcarpet-3.6.1/CHANGELOG.md +487 -0
- data/redcarpet-3.6.1/CONTRIBUTING.md +33 -0
- data/redcarpet-3.6.1/COPYING +20 -0
- data/redcarpet-3.6.1/Gemfile +9 -0
- data/redcarpet-3.6.1/README.markdown +405 -0
- data/redcarpet-3.6.1/Rakefile +60 -0
- data/redcarpet-3.6.1/bin/redcarpet +7 -0
- data/redcarpet-3.6.1/ext/redcarpet/autolink.c +308 -0
- data/redcarpet-3.6.1/ext/redcarpet/autolink.h +55 -0
- data/redcarpet-3.6.1/ext/redcarpet/buffer.c +203 -0
- data/redcarpet-3.6.1/ext/redcarpet/buffer.h +88 -0
- data/redcarpet-3.6.1/ext/redcarpet/extconf.rb +6 -0
- data/redcarpet-3.6.1/ext/redcarpet/houdini.h +51 -0
- data/redcarpet-3.6.1/ext/redcarpet/houdini_href_e.c +124 -0
- data/redcarpet-3.6.1/ext/redcarpet/houdini_html_e.c +104 -0
- data/redcarpet-3.6.1/ext/redcarpet/html.c +869 -0
- data/redcarpet-3.6.1/ext/redcarpet/html.h +83 -0
- data/redcarpet-3.6.1/ext/redcarpet/html_block_names.txt +44 -0
- data/redcarpet-3.6.1/ext/redcarpet/html_blocks.h +222 -0
- data/redcarpet-3.6.1/ext/redcarpet/html_smartypants.c +472 -0
- data/redcarpet-3.6.1/ext/redcarpet/markdown.c +2946 -0
- data/redcarpet-3.6.1/ext/redcarpet/markdown.h +143 -0
- data/redcarpet-3.6.1/ext/redcarpet/rc_markdown.c +194 -0
- data/redcarpet-3.6.1/ext/redcarpet/rc_render.c +601 -0
- data/redcarpet-3.6.1/ext/redcarpet/redcarpet.h +54 -0
- data/redcarpet-3.6.1/ext/redcarpet/stack.c +84 -0
- data/redcarpet-3.6.1/ext/redcarpet/stack.h +48 -0
- data/redcarpet-3.6.1/lib/redcarpet/cli.rb +86 -0
- data/redcarpet-3.6.1/lib/redcarpet/compat.rb +71 -0
- data/redcarpet-3.6.1/lib/redcarpet/render_man.rb +65 -0
- data/redcarpet-3.6.1/lib/redcarpet/render_strip.rb +60 -0
- data/redcarpet-3.6.1/lib/redcarpet.rb +92 -0
- data/redcarpet-3.6.1/redcarpet.gemspec +59 -0
- metadata +74 -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, "'");
|
|
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
|
+
* & --> &
|
|
35
|
+
* < --> <
|
|
36
|
+
* > --> >
|
|
37
|
+
* " --> "
|
|
38
|
+
* ' --> ' ' is not recommended
|
|
39
|
+
* / --> / 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
|
+
""",
|
|
64
|
+
"&",
|
|
65
|
+
"'",
|
|
66
|
+
"/",
|
|
67
|
+
"<",
|
|
68
|
+
">"
|
|
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
|
+
}
|