better_html 1.0.16 → 2.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/MIT-LICENSE +1 -0
- data/Rakefile +19 -14
- data/ext/better_html_ext/better_html.h +1 -0
- data/ext/better_html_ext/extconf.rb +16 -0
- data/ext/better_html_ext/html_tokenizer.c +12 -0
- data/ext/better_html_ext/html_tokenizer.h +7 -0
- data/ext/better_html_ext/parser.c +793 -0
- data/ext/better_html_ext/parser.h +93 -0
- data/ext/better_html_ext/tokenizer.c +717 -0
- data/ext/better_html_ext/tokenizer.h +80 -0
- data/lib/better_html/ast/iterator.rb +14 -9
- data/lib/better_html/ast/node.rb +4 -2
- data/lib/better_html/better_erb/erubi_implementation.rb +43 -39
- data/lib/better_html/better_erb/runtime_checks.rb +140 -133
- data/lib/better_html/better_erb/validated_output_buffer.rb +30 -22
- data/lib/better_html/better_erb.rb +58 -54
- data/lib/better_html/config.rb +7 -4
- data/lib/better_html/errors.rb +4 -2
- data/lib/better_html/helpers.rb +7 -3
- data/lib/better_html/html_attributes.rb +6 -2
- data/lib/better_html/parser.rb +21 -14
- data/lib/better_html/railtie.rb +8 -4
- data/lib/better_html/test_helper/ruby_node.rb +15 -10
- data/lib/better_html/test_helper/safe_erb/allowed_script_type.rb +8 -4
- data/lib/better_html/test_helper/safe_erb/base.rb +12 -9
- data/lib/better_html/test_helper/safe_erb/no_javascript_tag_helper.rb +7 -3
- data/lib/better_html/test_helper/safe_erb/no_statements.rb +7 -3
- data/lib/better_html/test_helper/safe_erb/script_interpolation.rb +9 -4
- data/lib/better_html/test_helper/safe_erb/tag_interpolation.rb +23 -20
- data/lib/better_html/test_helper/safe_erb_tester.rb +33 -31
- data/lib/better_html/test_helper/safe_lodash_tester.rb +36 -35
- data/lib/better_html/test_helper/safety_error.rb +2 -0
- data/lib/better_html/tokenizer/base_erb.rb +14 -10
- data/lib/better_html/tokenizer/html_erb.rb +3 -2
- data/lib/better_html/tokenizer/html_lodash.rb +22 -14
- data/lib/better_html/tokenizer/javascript_erb.rb +3 -1
- data/lib/better_html/tokenizer/location.rb +17 -6
- data/lib/better_html/tokenizer/token.rb +2 -0
- data/lib/better_html/tokenizer/token_array.rb +8 -8
- data/lib/better_html/tree/attribute.rb +10 -6
- data/lib/better_html/tree/attributes_list.rb +9 -5
- data/lib/better_html/tree/tag.rb +10 -6
- data/lib/better_html/version.rb +3 -1
- data/lib/better_html.rb +19 -17
- data/lib/tasks/better_html_tasks.rake +1 -0
- metadata +39 -147
- data/lib/better_html/better_erb/erubis_implementation.rb +0 -44
- data/test/better_html/better_erb/implementation_test.rb +0 -406
- data/test/better_html/errors_test.rb +0 -13
- data/test/better_html/helpers_test.rb +0 -49
- data/test/better_html/parser_test.rb +0 -314
- data/test/better_html/test_helper/ruby_node_test.rb +0 -288
- data/test/better_html/test_helper/safe_erb/allowed_script_type_test.rb +0 -46
- data/test/better_html/test_helper/safe_erb/no_javascript_tag_helper_test.rb +0 -37
- data/test/better_html/test_helper/safe_erb/no_statements_test.rb +0 -129
- data/test/better_html/test_helper/safe_erb/script_interpolation_test.rb +0 -149
- data/test/better_html/test_helper/safe_erb/tag_interpolation_test.rb +0 -303
- data/test/better_html/test_helper/safe_lodash_tester_test.rb +0 -90
- data/test/better_html/tokenizer/html_erb_test.rb +0 -180
- data/test/better_html/tokenizer/html_lodash_test.rb +0 -98
- data/test/better_html/tokenizer/location_test.rb +0 -75
- data/test/better_html/tokenizer/token_array_test.rb +0 -146
- data/test/better_html/tokenizer/token_test.rb +0 -15
- data/test/dummy/README.rdoc +0 -28
- data/test/dummy/Rakefile +0 -6
- data/test/dummy/app/assets/javascripts/application.js +0 -13
- data/test/dummy/app/assets/stylesheets/application.css +0 -15
- data/test/dummy/app/controllers/application_controller.rb +0 -5
- data/test/dummy/app/helpers/application_helper.rb +0 -2
- data/test/dummy/app/views/layouts/application.html.erb +0 -14
- data/test/dummy/bin/bundle +0 -3
- data/test/dummy/bin/rails +0 -4
- data/test/dummy/bin/rake +0 -4
- data/test/dummy/bin/setup +0 -29
- data/test/dummy/config/application.rb +0 -26
- data/test/dummy/config/boot.rb +0 -5
- data/test/dummy/config/database.yml +0 -25
- data/test/dummy/config/environment.rb +0 -5
- data/test/dummy/config/environments/development.rb +0 -41
- data/test/dummy/config/environments/production.rb +0 -79
- data/test/dummy/config/environments/test.rb +0 -42
- data/test/dummy/config/initializers/assets.rb +0 -11
- data/test/dummy/config/initializers/backtrace_silencers.rb +0 -7
- data/test/dummy/config/initializers/cookies_serializer.rb +0 -3
- data/test/dummy/config/initializers/filter_parameter_logging.rb +0 -4
- data/test/dummy/config/initializers/inflections.rb +0 -16
- data/test/dummy/config/initializers/mime_types.rb +0 -4
- data/test/dummy/config/initializers/session_store.rb +0 -3
- data/test/dummy/config/initializers/wrap_parameters.rb +0 -14
- data/test/dummy/config/locales/en.yml +0 -23
- data/test/dummy/config/routes.rb +0 -56
- data/test/dummy/config/secrets.yml +0 -22
- data/test/dummy/config.ru +0 -4
- data/test/dummy/public/404.html +0 -67
- data/test/dummy/public/422.html +0 -67
- data/test/dummy/public/500.html +0 -66
- data/test/dummy/public/favicon.ico +0 -0
- data/test/test_helper.rb +0 -29
@@ -0,0 +1,93 @@
|
|
1
|
+
#pragma once
|
2
|
+
#include "tokenizer.h"
|
3
|
+
|
4
|
+
enum parser_context {
|
5
|
+
PARSER_NONE,
|
6
|
+
PARSER_SOLIDUS_OR_TAG_NAME,
|
7
|
+
PARSER_TAG_NAME,
|
8
|
+
PARSER_TAG,
|
9
|
+
PARSER_ATTRIBUTE_NAME,
|
10
|
+
PARSER_ATTRIBUTE_WHITESPACE_OR_EQUAL,
|
11
|
+
PARSER_ATTRIBUTE_WHITESPACE_OR_VALUE,
|
12
|
+
PARSER_ATTRIBUTE_QUOTED_VALUE,
|
13
|
+
PARSER_SPACE_AFTER_ATTRIBUTE,
|
14
|
+
PARSER_ATTRIBUTE_UNQUOTED_VALUE,
|
15
|
+
PARSER_TAG_END,
|
16
|
+
PARSER_COMMENT,
|
17
|
+
PARSER_CDATA,
|
18
|
+
};
|
19
|
+
|
20
|
+
struct parser_document_error_t {
|
21
|
+
char *message;
|
22
|
+
long unsigned int pos;
|
23
|
+
long unsigned int mb_pos;
|
24
|
+
long unsigned int line_number;
|
25
|
+
long unsigned int column_number;
|
26
|
+
};
|
27
|
+
|
28
|
+
struct parser_document_t {
|
29
|
+
long unsigned int length;
|
30
|
+
char *data;
|
31
|
+
long unsigned int line_number;
|
32
|
+
long unsigned int column_number;
|
33
|
+
|
34
|
+
int enc_index;
|
35
|
+
long unsigned int mb_length;
|
36
|
+
};
|
37
|
+
|
38
|
+
struct token_reference_t {
|
39
|
+
enum token_type type;
|
40
|
+
long unsigned int start;
|
41
|
+
long unsigned int mb_start;
|
42
|
+
long unsigned int length;
|
43
|
+
long unsigned int line_number;
|
44
|
+
long unsigned int column_number;
|
45
|
+
};
|
46
|
+
|
47
|
+
struct parser_tag_t {
|
48
|
+
struct token_reference_t name;
|
49
|
+
int self_closing;
|
50
|
+
};
|
51
|
+
|
52
|
+
struct parser_attribute_t {
|
53
|
+
struct token_reference_t name;
|
54
|
+
struct token_reference_t value;
|
55
|
+
int is_quoted;
|
56
|
+
};
|
57
|
+
|
58
|
+
struct parser_rawtext_t {
|
59
|
+
struct token_reference_t text;
|
60
|
+
};
|
61
|
+
|
62
|
+
struct parser_comment_t {
|
63
|
+
struct token_reference_t text;
|
64
|
+
};
|
65
|
+
|
66
|
+
struct parser_cdata_t {
|
67
|
+
struct token_reference_t text;
|
68
|
+
};
|
69
|
+
|
70
|
+
struct parser_t
|
71
|
+
{
|
72
|
+
struct tokenizer_t tk;
|
73
|
+
|
74
|
+
struct parser_document_t doc;
|
75
|
+
|
76
|
+
size_t errors_count;
|
77
|
+
struct parser_document_error_t *errors;
|
78
|
+
|
79
|
+
enum parser_context context;
|
80
|
+
struct parser_tag_t tag;
|
81
|
+
struct parser_attribute_t attribute;
|
82
|
+
struct parser_rawtext_t rawtext;
|
83
|
+
struct parser_comment_t comment;
|
84
|
+
struct parser_cdata_t cdata;
|
85
|
+
};
|
86
|
+
|
87
|
+
void Init_html_tokenizer_parser(VALUE mHtmlTokenizer);
|
88
|
+
|
89
|
+
extern const rb_data_type_t ht_parser_data_type;
|
90
|
+
#define Parser_Get_Struct(obj, sval) TypedData_Get_Struct(obj, struct parser_t, &ht_parser_data_type, sval)
|
91
|
+
|
92
|
+
#define PARSE_AGAIN return 1
|
93
|
+
#define PARSE_DONE return 0
|