hamlit 2.5.0 → 2.6.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +4 -0
- data/CHANGELOG.md +7 -0
- data/README.md +7 -0
- data/ext/hamlit/extconf.rb +5 -13
- data/ext/hamlit/hamlit.c +7 -6
- data/ext/hamlit/hescape.c +108 -0
- data/ext/hamlit/hescape.h +20 -0
- data/hamlit.gemspec +1 -1
- data/lib/hamlit/version.rb +1 -1
- metadata +4 -23
- data/.gitmodules +0 -3
- data/ext/hamlit/houdini/.gitignore +0 -3
- data/ext/hamlit/houdini/COPYING +0 -7
- data/ext/hamlit/houdini/Makefile +0 -79
- data/ext/hamlit/houdini/README.md +0 -59
- data/ext/hamlit/houdini/buffer.c +0 -249
- data/ext/hamlit/houdini/buffer.h +0 -113
- data/ext/hamlit/houdini/houdini.h +0 -46
- data/ext/hamlit/houdini/houdini_href_e.c +0 -115
- data/ext/hamlit/houdini/houdini_html_e.c +0 -90
- data/ext/hamlit/houdini/houdini_html_u.c +0 -122
- data/ext/hamlit/houdini/houdini_js_e.c +0 -90
- data/ext/hamlit/houdini/houdini_js_u.c +0 -60
- data/ext/hamlit/houdini/houdini_uri_e.c +0 -107
- data/ext/hamlit/houdini/houdini_uri_u.c +0 -68
- data/ext/hamlit/houdini/houdini_xml_e.c +0 -136
- data/ext/hamlit/houdini/html_unescape.gperf +0 -258
- data/ext/hamlit/houdini/html_unescape.h +0 -754
- data/ext/hamlit/houdini/tools/build_table.py +0 -13
- data/ext/hamlit/houdini/tools/build_tables.c +0 -51
- data/ext/hamlit/houdini/tools/wikipedia_table.txt +0 -2025
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: acd45b093acf5ae8f7120e1e7e595028fa78915b
|
4
|
+
data.tar.gz: cf875adfcd85ff188fdc10efdb0af616cb2fd993
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 48cdaa2c88be9efe9a526f025c94ed30ec6a597971097a5976f502d74ab4914f08635ceccdc4aa38f226419920a775b50a5f4f42c3b54a7afdf87974ea6778ce
|
7
|
+
data.tar.gz: f7cf63537580965878635d161a4c619caba202f5e0f1626f5f4a7bcd6bd28fb96ce7b421a2ba57a3966ee0dcf2f1c6fcc5273eb7b32cf920108b777c0ce5193c
|
data/.travis.yml
CHANGED
@@ -13,6 +13,8 @@ matrix:
|
|
13
13
|
env: TASK=test
|
14
14
|
- rvm: 2.3.1
|
15
15
|
env: TASK=test
|
16
|
+
- rvm: ruby-head
|
17
|
+
env: TASK=test
|
16
18
|
- rvm: 2.3.1
|
17
19
|
env: TASK=bench TEMPLATE=benchmark/boolean_attribute.haml,benchmark/class_attribute.haml,benchmark/id_attribute.haml,benchmark/data_attribute.haml,benchmark/common_attribute.haml
|
18
20
|
- rvm: 2.3.1
|
@@ -28,6 +30,8 @@ matrix:
|
|
28
30
|
- rvm: 2.3.1
|
29
31
|
env: TASK=bench TEMPLATE=test/haml/templates/standard.haml COMPILE=1
|
30
32
|
allow_failures:
|
33
|
+
- rvm: ruby-head
|
34
|
+
env: TASK=test
|
31
35
|
- env: TASK=bench TEMPLATE=benchmark/boolean_attribute.haml,benchmark/class_attribute.haml,benchmark/id_attribute.haml,benchmark/data_attribute.haml,benchmark/common_attribute.haml
|
32
36
|
- env: TASK=bench TEMPLATE=benchmark/dynamic_attributes/boolean_attribute.haml,benchmark/dynamic_attributes/class_attribute.haml,benchmark/dynamic_attributes/id_attribute.haml,benchmark/dynamic_attributes/data_attribute.haml,benchmark/dynamic_attributes/common_attribute.haml
|
33
37
|
- env: TASK=bench SLIM_BENCH=1
|
data/CHANGELOG.md
CHANGED
@@ -4,6 +4,13 @@ All notable changes to this project will be documented in this file. This
|
|
4
4
|
project adheres to [Semantic Versioning](http://semver.org/). This change log is based upon
|
5
5
|
[keep-a-changelog](https://github.com/olivierlacan/keep-a-changelog).
|
6
6
|
|
7
|
+
## [2.6.0](https://github.com/k0kubun/hamlit/compare/v2.5.0...v2.6.0) - 2016-08-14
|
8
|
+
|
9
|
+
### Changed
|
10
|
+
|
11
|
+
- Stop using [houdini](https://github.com/vmg/houdini) and rewrite HTML escape function to resolve building or packaging problems [#82](https://github.com/k0kubun/hamlit/pull/82).
|
12
|
+
- No behavior is changed
|
13
|
+
|
7
14
|
## [2.5.0](https://github.com/k0kubun/hamlit/compare/v2.4.2...v2.5.0) - 2016-06-04
|
8
15
|
|
9
16
|
### Changed
|
data/README.md
CHANGED
@@ -103,6 +103,13 @@ $ hamlit render in.haml
|
|
103
103
|
|
104
104
|
## Contributing
|
105
105
|
|
106
|
+
### Test latest version
|
107
|
+
|
108
|
+
```rb
|
109
|
+
# Gemfile
|
110
|
+
gem 'hamlit', github: 'k0kubun/hamlit', submodules: true
|
111
|
+
```
|
112
|
+
|
106
113
|
### Development
|
107
114
|
|
108
115
|
Contributions are welcomed. It'd be good to see
|
data/ext/hamlit/extconf.rb
CHANGED
@@ -1,18 +1,10 @@
|
|
1
1
|
require 'mkmf'
|
2
2
|
|
3
|
-
|
4
|
-
$INCFLAGS << " -I#{houdini_dir}"
|
5
|
-
$CFLAGS << ' -Wall -Wextra'
|
3
|
+
$CFLAGS << ' -Wall -Wextra'
|
6
4
|
|
7
|
-
$srcs = %w[
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
FileUtils.cp(path, src)
|
12
|
-
else
|
13
|
-
FileUtils.ln_s(path, src, force: true)
|
14
|
-
end
|
15
|
-
$srcs << src
|
16
|
-
end
|
5
|
+
$srcs = %w[
|
6
|
+
hamlit.c
|
7
|
+
hescape.c
|
8
|
+
]
|
17
9
|
|
18
10
|
create_makefile('hamlit/hamlit')
|
data/ext/hamlit/hamlit.c
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
#include <ruby.h>
|
2
2
|
#include <ruby/encoding.h>
|
3
|
-
#include "
|
3
|
+
#include "hescape.h"
|
4
4
|
#include "string.h"
|
5
5
|
|
6
6
|
VALUE mAttributeBuilder, mObjectRef;
|
@@ -58,13 +58,14 @@ hyphenate(VALUE str)
|
|
58
58
|
static VALUE
|
59
59
|
escape_html(VALUE str)
|
60
60
|
{
|
61
|
-
|
62
|
-
|
61
|
+
char *buf;
|
62
|
+
unsigned int size;
|
63
63
|
Check_Type(str, T_STRING);
|
64
64
|
|
65
|
-
|
66
|
-
|
67
|
-
|
65
|
+
size = hesc_escape_html(&buf, RSTRING_PTR(str), RSTRING_LEN(str));
|
66
|
+
if (size > RSTRING_LEN(str)) {
|
67
|
+
str = rb_enc_str_new(buf, size, rb_utf8_encoding());
|
68
|
+
free((void *)buf);
|
68
69
|
}
|
69
70
|
|
70
71
|
return str;
|
@@ -0,0 +1,108 @@
|
|
1
|
+
#include <stdio.h>
|
2
|
+
#include <string.h>
|
3
|
+
#include <stdlib.h>
|
4
|
+
#include "hescape.h"
|
5
|
+
|
6
|
+
static const char *ESCAPED_STRING[] = {
|
7
|
+
"",
|
8
|
+
""",
|
9
|
+
"&",
|
10
|
+
"'",
|
11
|
+
"<",
|
12
|
+
">",
|
13
|
+
};
|
14
|
+
|
15
|
+
// This is strlen(ESCAPED_STRING[x]) optimized specially.
|
16
|
+
// Mapping: 1 => 6, 2 => 5, 3 => 5, 4 => 4, 5 => 4
|
17
|
+
#define ESC_LEN(x) ((13 - x) / 2)
|
18
|
+
|
19
|
+
/*
|
20
|
+
* Given ASCII-compatible character, return index of ESCAPED_STRING.
|
21
|
+
*
|
22
|
+
* " (34) => 1 (")
|
23
|
+
* & (38) => 2 (&)
|
24
|
+
* ' (39) => 3 (')
|
25
|
+
* < (60) => 4 (<)
|
26
|
+
* > (62) => 5 (>)
|
27
|
+
*/
|
28
|
+
static const char HTML_ESCAPE_TABLE[] = {
|
29
|
+
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
30
|
+
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
31
|
+
0, 0, 1, 0, 0, 0, 2, 3, 0, 0, 0, 0, 0, 0, 0, 0,
|
32
|
+
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 4, 0, 5, 0,
|
33
|
+
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
34
|
+
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
35
|
+
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
36
|
+
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
37
|
+
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
38
|
+
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
39
|
+
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
40
|
+
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
41
|
+
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
42
|
+
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
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
|
+
};
|
46
|
+
|
47
|
+
static char*
|
48
|
+
ensure_allocated(char *buf, size_t size, size_t *asize)
|
49
|
+
{
|
50
|
+
size_t new_size;
|
51
|
+
|
52
|
+
if (size < *asize)
|
53
|
+
return buf;
|
54
|
+
|
55
|
+
if (*asize == 0) {
|
56
|
+
new_size = size;
|
57
|
+
} else {
|
58
|
+
new_size = *asize;
|
59
|
+
}
|
60
|
+
|
61
|
+
// Increase buffer size by 1.5x if realloced multiple times.
|
62
|
+
while (new_size < size)
|
63
|
+
new_size = (new_size << 1) - (new_size >> 1);
|
64
|
+
|
65
|
+
// Round allocation up to multiple of 8.
|
66
|
+
new_size = (new_size + 7) & ~7;
|
67
|
+
|
68
|
+
*asize = new_size;
|
69
|
+
return realloc(buf, new_size);
|
70
|
+
}
|
71
|
+
|
72
|
+
size_t
|
73
|
+
hesc_escape_html(char **dest, const char *buf, size_t size)
|
74
|
+
{
|
75
|
+
size_t asize = 0, esc_i, esize = 0, i = 0, rbuf_end = 0;
|
76
|
+
const char *esc;
|
77
|
+
char *rbuf = NULL;
|
78
|
+
|
79
|
+
while (i < size) {
|
80
|
+
// Loop here to skip non-escaped characters fast.
|
81
|
+
while (i < size && (esc_i = HTML_ESCAPE_TABLE[(unsigned char)buf[i]]) == 0)
|
82
|
+
i++;
|
83
|
+
|
84
|
+
if (i < size && esc_i) {
|
85
|
+
esc = ESCAPED_STRING[esc_i];
|
86
|
+
rbuf = ensure_allocated(rbuf, sizeof(char) * (size + esize + ESC_LEN(esc_i) + 1), &asize);
|
87
|
+
|
88
|
+
// Copy pending characters and escaped string.
|
89
|
+
memmove(rbuf + rbuf_end, buf + (rbuf_end - esize), i - (rbuf_end - esize));
|
90
|
+
memmove(rbuf + i + esize, esc, ESC_LEN(esc_i));
|
91
|
+
rbuf_end = i + esize + ESC_LEN(esc_i);
|
92
|
+
esize += ESC_LEN(esc_i) - 1;
|
93
|
+
}
|
94
|
+
i++;
|
95
|
+
}
|
96
|
+
|
97
|
+
if (rbuf_end == 0) {
|
98
|
+
// Return given buf and size if there are no escaped characters.
|
99
|
+
*dest = (char *)buf;
|
100
|
+
return size;
|
101
|
+
} else {
|
102
|
+
// Copy pending characters including NULL character.
|
103
|
+
memmove(rbuf + rbuf_end, buf + (rbuf_end - esize), (size + 1) - (rbuf_end - esize));
|
104
|
+
|
105
|
+
*dest = rbuf;
|
106
|
+
return size + esize;
|
107
|
+
}
|
108
|
+
}
|
@@ -0,0 +1,20 @@
|
|
1
|
+
#ifndef HESCAPE_H
|
2
|
+
#define HESCAPE_H
|
3
|
+
|
4
|
+
#include <sys/types.h>
|
5
|
+
|
6
|
+
/*
|
7
|
+
* Replace characters according to the following rules.
|
8
|
+
* Note that this function can handle only ASCII-compatible string.
|
9
|
+
*
|
10
|
+
* " => "
|
11
|
+
* & => &
|
12
|
+
* ' => '
|
13
|
+
* < => <
|
14
|
+
* > => >
|
15
|
+
*
|
16
|
+
* @return size of dest. If it's larger than len, dest is required to be freed.
|
17
|
+
*/
|
18
|
+
extern size_t hesc_escape_html(char **dest, const char *src, size_t size);
|
19
|
+
|
20
|
+
#endif
|
data/hamlit.gemspec
CHANGED
@@ -14,7 +14,7 @@ Gem::Specification.new do |spec|
|
|
14
14
|
spec.homepage = 'https://github.com/k0kubun/hamlit'
|
15
15
|
spec.license = 'MIT'
|
16
16
|
|
17
|
-
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features|sample)/}) }
|
17
|
+
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features|sample)/}) }
|
18
18
|
spec.bindir = 'exe'
|
19
19
|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
20
20
|
spec.extensions = ['ext/hamlit/extconf.rb']
|
data/lib/hamlit/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: hamlit
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.
|
4
|
+
version: 2.6.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Takashi Kokubun
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-
|
11
|
+
date: 2016-08-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: temple
|
@@ -244,7 +244,6 @@ extensions:
|
|
244
244
|
extra_rdoc_files: []
|
245
245
|
files:
|
246
246
|
- ".gitignore"
|
247
|
-
- ".gitmodules"
|
248
247
|
- ".travis.yml"
|
249
248
|
- CHANGELOG.md
|
250
249
|
- Gemfile
|
@@ -290,26 +289,8 @@ files:
|
|
290
289
|
- exe/hamlit
|
291
290
|
- ext/hamlit/extconf.rb
|
292
291
|
- ext/hamlit/hamlit.c
|
293
|
-
- ext/hamlit/
|
294
|
-
- ext/hamlit/
|
295
|
-
- ext/hamlit/houdini/Makefile
|
296
|
-
- ext/hamlit/houdini/README.md
|
297
|
-
- ext/hamlit/houdini/buffer.c
|
298
|
-
- ext/hamlit/houdini/buffer.h
|
299
|
-
- ext/hamlit/houdini/houdini.h
|
300
|
-
- ext/hamlit/houdini/houdini_href_e.c
|
301
|
-
- ext/hamlit/houdini/houdini_html_e.c
|
302
|
-
- ext/hamlit/houdini/houdini_html_u.c
|
303
|
-
- ext/hamlit/houdini/houdini_js_e.c
|
304
|
-
- ext/hamlit/houdini/houdini_js_u.c
|
305
|
-
- ext/hamlit/houdini/houdini_uri_e.c
|
306
|
-
- ext/hamlit/houdini/houdini_uri_u.c
|
307
|
-
- ext/hamlit/houdini/houdini_xml_e.c
|
308
|
-
- ext/hamlit/houdini/html_unescape.gperf
|
309
|
-
- ext/hamlit/houdini/html_unescape.h
|
310
|
-
- ext/hamlit/houdini/tools/build_table.py
|
311
|
-
- ext/hamlit/houdini/tools/build_tables.c
|
312
|
-
- ext/hamlit/houdini/tools/wikipedia_table.txt
|
292
|
+
- ext/hamlit/hescape.c
|
293
|
+
- ext/hamlit/hescape.h
|
313
294
|
- hamlit.gemspec
|
314
295
|
- lib/hamlit.rb
|
315
296
|
- lib/hamlit/attribute_builder.rb
|
data/.gitmodules
DELETED
data/ext/hamlit/houdini/COPYING
DELETED
@@ -1,7 +0,0 @@
|
|
1
|
-
Copyright (C) 2012 Vicent Martí
|
2
|
-
|
3
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
4
|
-
|
5
|
-
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
6
|
-
|
7
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/ext/hamlit/houdini/Makefile
DELETED
@@ -1,79 +0,0 @@
|
|
1
|
-
# GNU Makefile
|
2
|
-
# Copyright (C) 2012 Przemyslaw Pawelczyk <przemoc@gmail.com>
|
3
|
-
#
|
4
|
-
# Permission is hereby granted, free of charge, to any person obtaining a
|
5
|
-
# copy of this software and associated documentation files (the
|
6
|
-
# "Software"), to deal in the Software without restriction, including
|
7
|
-
# without limitation the rights to use, copy, modify, merge, publish,
|
8
|
-
# distribute, sublicense, and/or sell copies of the Software, and to
|
9
|
-
# permit persons to whom the Software is furnished to do so, subject to
|
10
|
-
# the following conditions:
|
11
|
-
#
|
12
|
-
# The above copyright notice and this permission notice shall be included
|
13
|
-
# in all copies or substantial portions of the Software.
|
14
|
-
#
|
15
|
-
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
16
|
-
# OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
17
|
-
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
18
|
-
# IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
19
|
-
# CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
20
|
-
# TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
21
|
-
# SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
22
|
-
|
23
|
-
SRCS := buffer.c houdini_href_e.c houdini_html_e.c houdini_html_u.c houdini_js_e.c houdini_js_u.c houdini_uri_e.c houdini_uri_u.c houdini_xml_e.c
|
24
|
-
OBJS := $(addsuffix .o,$(basename $(SRCS)))
|
25
|
-
DEPS := $(addsuffix .d,$(basename $(SRCS)))
|
26
|
-
NAME := houdini
|
27
|
-
|
28
|
-
SRCDIR := $(dir $(lastword $(MAKEFILE_LIST)))
|
29
|
-
OBJDIR ?= ./
|
30
|
-
OBJS := $(addprefix $(OBJDIR),$(OBJS))
|
31
|
-
SLIB := lib$(NAME).a
|
32
|
-
|
33
|
-
vpath %.c $(SRCDIR)
|
34
|
-
vpath %.h $(SRCDIR)
|
35
|
-
|
36
|
-
AR ?= ar
|
37
|
-
CC ?= gcc
|
38
|
-
GPERF ?= gperf
|
39
|
-
SED ?= sed
|
40
|
-
|
41
|
-
CFLAGS ?= -O2
|
42
|
-
# -Wno-missing-field-initializers - gperf's header doesn't pass on -Wextra
|
43
|
-
MANDATORY_FLAGS := -Wall -Wextra -Wno-missing-field-initializers
|
44
|
-
override CFLAGS := $(MANDATORY_FLAGS) $(CFLAGS)
|
45
|
-
|
46
|
-
.PHONY: all clean objects package
|
47
|
-
|
48
|
-
all: package
|
49
|
-
|
50
|
-
objects: $(OBJS)
|
51
|
-
package: $(SLIB)
|
52
|
-
|
53
|
-
$(SLIB): $(OBJS)
|
54
|
-
$(AR) rcs $@ $^
|
55
|
-
|
56
|
-
$(OBJS): | $(OBJDIR)
|
57
|
-
|
58
|
-
$(OBJDIR):
|
59
|
-
mkdir -p $@
|
60
|
-
|
61
|
-
$(OBJDIR)%.o: %.c
|
62
|
-
$(CC) $(CFLAGS) $(CPPFLAGS) $(TARGET_ARCH) -c -o $@ $<
|
63
|
-
|
64
|
-
%.d: %.c
|
65
|
-
@set -e; \
|
66
|
-
$(RM) $@; \
|
67
|
-
$(CC) -MM $(CFLAGS) $(CPPFLAGS) $(TARGET_ARCH) $< >$@.tmp; \
|
68
|
-
$(SED) 's,\($*\)\.o[ :]*,$$(OBJDIR)\1.o $@: ,g' <$@.tmp >$@; \
|
69
|
-
$(RM) $@.tmp
|
70
|
-
|
71
|
-
html_unescape.h: html_unescape.gperf
|
72
|
-
$(GPERF) -t -N find_entity -H hash_entity -K entity -C -l --null-strings -m100 $< >$@
|
73
|
-
|
74
|
-
clean:
|
75
|
-
$(RM) $(SLIB) $(OBJS) $(DEPS)
|
76
|
-
|
77
|
-
ifneq ($(MAKECMDGOALS),clean)
|
78
|
-
-include $(DEPS)
|
79
|
-
endif
|
@@ -1,59 +0,0 @@
|
|
1
|
-
Houdini - The Escapist
|
2
|
-
======================
|
3
|
-
|
4
|
-
Houdini doesn't quite qualify as a library. In fact, I didn't even bother
|
5
|
-
to write a Makefile (well, others did). It's zero-dependency and modular.
|
6
|
-
Just stick the files you need in your project. Or go with all of them
|
7
|
-
(e.g. via git submodule) and use the static library that is built by
|
8
|
-
default when GNU make is invoked. Now you can freely escape some shit.
|
9
|
-
|
10
|
-
Houdini is a simple API for escaping text for the web. And unescaping it.
|
11
|
-
But that kind of breaks the joke in the name so nevermind.
|
12
|
-
|
13
|
-
- HTML escaping follows the OWASP suggestion. All other entities are left
|
14
|
-
as-is.
|
15
|
-
|
16
|
-
& --> &
|
17
|
-
< --> <
|
18
|
-
> --> >
|
19
|
-
" --> "
|
20
|
-
' --> ' ' is not recommended
|
21
|
-
/ --> / forward slash is included as it helps end an HTML entity
|
22
|
-
|
23
|
-
- HTML unescaping is fully RFC-compliant. Yes, that's the 253 different entities
|
24
|
-
for you, and decimal/hex code point specifiers.
|
25
|
-
|
26
|
-
- URI escaping and unescaping is fully RFC-compliant.
|
27
|
-
|
28
|
-
- URL escaping and unescaping is the same as generic URIs,
|
29
|
-
but spaces are changed to `+`.
|
30
|
-
|
31
|
-
**WARNING:** Houdini parses **only** UTF-8 strings, and generates **only**
|
32
|
-
UTF-8 strings. If you are using another encoding, you should probably transcode
|
33
|
-
*before* passing the buffer to Houdini.
|
34
|
-
|
35
|
-
### Current API:
|
36
|
-
|
37
|
-
Do you really need docs for this?
|
38
|
-
|
39
|
-
~~~~ c
|
40
|
-
int houdini_escape_html(gh_buf *ob, const uint8_t *src, size_t size);
|
41
|
-
int houdini_escape_html0(gh_buf *ob, const uint8_t *src, size_t size, int secure);
|
42
|
-
int houdini_unescape_html(gh_buf *ob, const uint8_t *src, size_t size);
|
43
|
-
int houdini_escape_xml(gh_buf *ob, const uint8_t *src, size_t size);
|
44
|
-
int houdini_escape_uri(gh_buf *ob, const uint8_t *src, size_t size);
|
45
|
-
int houdini_escape_url(gh_buf *ob, const uint8_t *src, size_t size);
|
46
|
-
int houdini_escape_href(gh_buf *ob, const uint8_t *src, size_t size);
|
47
|
-
int houdini_unescape_uri(gh_buf *ob, const uint8_t *src, size_t size);
|
48
|
-
int houdini_unescape_url(gh_buf *ob, const uint8_t *src, size_t size);
|
49
|
-
int houdini_escape_js(gh_buf *ob, const uint8_t *src, size_t size);
|
50
|
-
int houdini_unescape_js(gh_buf *ob, const uint8_t *src, size_t size);
|
51
|
-
~~~~
|
52
|
-
|
53
|
-
Pass your string. It'll get escaped/unescaped in the target buffer, and the call will return 1.
|
54
|
-
If the given string has nothing to escape/unescape, the call will return 0 and the
|
55
|
-
output buffer will be empty.
|
56
|
-
|
57
|
-
### Questions?
|
58
|
-
|
59
|
-
Open an issue. Or shout angrily at me on Twitter ([@vmg](https://twitter.com/vmg)).
|