romanbsd-tarantula 0.1.8
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG +47 -0
- data/MIT-LICENSE +20 -0
- data/README.rdoc +162 -0
- data/Rakefile +69 -0
- data/VERSION.yml +4 -0
- data/examples/example_helper.rb +48 -0
- data/examples/relevance/core_extensions/ellipsize_example.rb +19 -0
- data/examples/relevance/core_extensions/file_example.rb +8 -0
- data/examples/relevance/core_extensions/response_example.rb +29 -0
- data/examples/relevance/core_extensions/test_case_example.rb +20 -0
- data/examples/relevance/tarantula/attack_form_submission_example.rb +79 -0
- data/examples/relevance/tarantula/attack_handler_example.rb +29 -0
- data/examples/relevance/tarantula/crawler_example.rb +386 -0
- data/examples/relevance/tarantula/form_example.rb +50 -0
- data/examples/relevance/tarantula/form_submission_example.rb +71 -0
- data/examples/relevance/tarantula/html_document_handler_example.rb +43 -0
- data/examples/relevance/tarantula/html_report_helper_example.rb +46 -0
- data/examples/relevance/tarantula/html_reporter_example.rb +82 -0
- data/examples/relevance/tarantula/invalid_html_handler_example.rb +33 -0
- data/examples/relevance/tarantula/io_reporter_example.rb +11 -0
- data/examples/relevance/tarantula/link_example.rb +67 -0
- data/examples/relevance/tarantula/log_grabber_example.rb +26 -0
- data/examples/relevance/tarantula/rails_integration_proxy_example.rb +88 -0
- data/examples/relevance/tarantula/result_example.rb +85 -0
- data/examples/relevance/tarantula/tidy_handler_example.rb +58 -0
- data/examples/relevance/tarantula/transform_example.rb +20 -0
- data/examples/relevance/tarantula/w3c_validator_example.rb +71 -0
- data/examples/relevance/tarantula_example.rb +23 -0
- data/laf/images/button_active.png +0 -0
- data/laf/images/button_hover.png +0 -0
- data/laf/images/button_inactive.png +0 -0
- data/laf/images/header_bg.jpg +0 -0
- data/laf/images/logo.png +0 -0
- data/laf/images/tagline.png +0 -0
- data/laf/javascripts/jquery-1.2.3.js +3408 -0
- data/laf/javascripts/jquery-ui-tabs.js +890 -0
- data/laf/javascripts/jquery.tablesorter.js +861 -0
- data/laf/javascripts/niftyLayout.js +11 -0
- data/laf/javascripts/niftycube-details.js +298 -0
- data/laf/javascripts/niftycube.js +298 -0
- data/laf/javascripts/tarantula.js +10 -0
- data/laf/stylesheets/tarantula.css +345 -0
- data/laf/v2/detail.html +59 -0
- data/laf/v2/images/button_active.png +0 -0
- data/laf/v2/images/button_hover.png +0 -0
- data/laf/v2/images/button_inactive.png +0 -0
- data/laf/v2/images/header_bg.jpg +0 -0
- data/laf/v2/images/logo.png +0 -0
- data/laf/v2/images/tagline.png +0 -0
- data/laf/v2/index.html +77 -0
- data/laf/v2/stylesheets/tarantula.v2.css +324 -0
- data/lib/relevance/core_extensions/ellipsize.rb +34 -0
- data/lib/relevance/core_extensions/file.rb +9 -0
- data/lib/relevance/core_extensions/metaclass.rb +78 -0
- data/lib/relevance/core_extensions/response.rb +9 -0
- data/lib/relevance/core_extensions/string_chars_fix.rb +11 -0
- data/lib/relevance/core_extensions/test_case.rb +19 -0
- data/lib/relevance/tarantula/attack.rb +15 -0
- data/lib/relevance/tarantula/attack_form_submission.rb +75 -0
- data/lib/relevance/tarantula/attack_handler.rb +37 -0
- data/lib/relevance/tarantula/crawler.rb +264 -0
- data/lib/relevance/tarantula/detail.html.erb +82 -0
- data/lib/relevance/tarantula/form.rb +21 -0
- data/lib/relevance/tarantula/form_submission.rb +70 -0
- data/lib/relevance/tarantula/html_document_handler.rb +36 -0
- data/lib/relevance/tarantula/html_report_helper.rb +39 -0
- data/lib/relevance/tarantula/html_reporter.rb +105 -0
- data/lib/relevance/tarantula/index.html.erb +37 -0
- data/lib/relevance/tarantula/invalid_html_handler.rb +18 -0
- data/lib/relevance/tarantula/io_reporter.rb +34 -0
- data/lib/relevance/tarantula/link.rb +56 -0
- data/lib/relevance/tarantula/log_grabber.rb +16 -0
- data/lib/relevance/tarantula/rails_integration_proxy.rb +68 -0
- data/lib/relevance/tarantula/recording.rb +12 -0
- data/lib/relevance/tarantula/response.rb +13 -0
- data/lib/relevance/tarantula/result.rb +66 -0
- data/lib/relevance/tarantula/test_report.html.erb +32 -0
- data/lib/relevance/tarantula/tidy_handler.rb +32 -0
- data/lib/relevance/tarantula/transform.rb +17 -0
- data/lib/relevance/tarantula/w3c_validator.rb +33 -0
- data/lib/relevance/tarantula.rb +59 -0
- data/tasks/tarantula_tasks.rake +36 -0
- data/template/tarantula_test.rb +22 -0
- data/vendor/w3c_validators/CHANGELOG +14 -0
- data/vendor/w3c_validators/LICENSE +60 -0
- data/vendor/w3c_validators/README +120 -0
- data/vendor/w3c_validators/README.svn +4 -0
- data/vendor/w3c_validators/lib/w3c_validators/constants.rb +80 -0
- data/vendor/w3c_validators/lib/w3c_validators/css_validator.rb +149 -0
- data/vendor/w3c_validators/lib/w3c_validators/exceptions.rb +4 -0
- data/vendor/w3c_validators/lib/w3c_validators/feed_validator.rb +110 -0
- data/vendor/w3c_validators/lib/w3c_validators/markup_validator.rb +227 -0
- data/vendor/w3c_validators/lib/w3c_validators/message.rb +82 -0
- data/vendor/w3c_validators/lib/w3c_validators/results.rb +62 -0
- data/vendor/w3c_validators/lib/w3c_validators/validator.rb +157 -0
- data/vendor/w3c_validators/lib/w3c_validators.rb +5 -0
- data/vendor/w3c_validators/rakefile.rb +53 -0
- data/vendor/w3c_validators/test/fixtures/invalid_css.css +2 -0
- data/vendor/w3c_validators/test/fixtures/invalid_encoding.html +10 -0
- data/vendor/w3c_validators/test/fixtures/invalid_feed.xml +19 -0
- data/vendor/w3c_validators/test/fixtures/invalid_html5.html +16 -0
- data/vendor/w3c_validators/test/fixtures/invalid_markup.html +11 -0
- data/vendor/w3c_validators/test/fixtures/valid_css.css +2 -0
- data/vendor/w3c_validators/test/fixtures/valid_feed.xml +20 -0
- data/vendor/w3c_validators/test/fixtures/valid_html5.html +16 -0
- data/vendor/w3c_validators/test/fixtures/valid_markup.html +11 -0
- data/vendor/w3c_validators/test/test_css_validator.rb +51 -0
- data/vendor/w3c_validators/test/test_exceptions.rb +35 -0
- data/vendor/w3c_validators/test/test_feed_validator.rb +61 -0
- data/vendor/w3c_validators/test/test_helper.rb +6 -0
- data/vendor/w3c_validators/test/test_html5_validator.rb +64 -0
- data/vendor/w3c_validators/test/test_markup_validator.rb +94 -0
- data/vendor/xss-shield/MIT-LICENSE +20 -0
- data/vendor/xss-shield/README +76 -0
- data/vendor/xss-shield/init.rb +16 -0
- data/vendor/xss-shield/lib/xss_shield/erb_hacks.rb +111 -0
- data/vendor/xss-shield/lib/xss_shield/haml_hacks.rb +42 -0
- data/vendor/xss-shield/lib/xss_shield/safe_string.rb +47 -0
- data/vendor/xss-shield/lib/xss_shield/secure_helpers.rb +40 -0
- data/vendor/xss-shield/lib/xss_shield.rb +6 -0
- data/vendor/xss-shield/test/test_actionview_integration.rb +40 -0
- data/vendor/xss-shield/test/test_erb.rb +44 -0
- data/vendor/xss-shield/test/test_haml.rb +43 -0
- data/vendor/xss-shield/test/test_helpers.rb +25 -0
- data/vendor/xss-shield/test/test_safe_string.rb +55 -0
- metadata +218 -0
@@ -0,0 +1,82 @@
|
|
1
|
+
module W3CValidators
|
2
|
+
class Message
|
3
|
+
attr_accessor :type, :line, :col, :source, :explanation, :message, :message_id
|
4
|
+
attr_accessor :message_count, :element, :parent, :value
|
5
|
+
|
6
|
+
MESSAGE_TYPES = [:warning, :error]
|
7
|
+
|
8
|
+
# Due to the responses received from the W3C's validators, different data
|
9
|
+
# are available for different validation types.
|
10
|
+
#
|
11
|
+
# ==== Feed validation
|
12
|
+
# * +line+
|
13
|
+
# * +col+
|
14
|
+
# * +message+ (originally +text+)
|
15
|
+
# * +message_count+
|
16
|
+
# * +element+
|
17
|
+
# * +parent+
|
18
|
+
# * +value+
|
19
|
+
# See http://validator.w3.org/feed/docs/soap.html#soap12message for full explanations.
|
20
|
+
#
|
21
|
+
# ==== Markup validation
|
22
|
+
# * +line+
|
23
|
+
# * +col+
|
24
|
+
# * +message+
|
25
|
+
# * +message_id+
|
26
|
+
# * +explanation+
|
27
|
+
# * +source+
|
28
|
+
# See http://validator.w3.org/docs/api.html#soap12message for full explanations.
|
29
|
+
#
|
30
|
+
# ==== CSS validation (http://jigsaw.w3.org/css-validator/api.html#soap12message)
|
31
|
+
# * +level+
|
32
|
+
# * +line+
|
33
|
+
# * +message+
|
34
|
+
# See http://jigsaw.w3.org/css-validator/api.html#soap12message for full explanations.
|
35
|
+
def initialize(uri, message_type, options = {})
|
36
|
+
@type = message_type
|
37
|
+
@uri = uri
|
38
|
+
|
39
|
+
# All validators
|
40
|
+
@line = options[:line]
|
41
|
+
@col = options[:col]
|
42
|
+
|
43
|
+
# MarkupValidator
|
44
|
+
@source = options[:source]
|
45
|
+
@explanation = options[:explanation]
|
46
|
+
@message = options[:message]
|
47
|
+
@message_id = options[:messageid]
|
48
|
+
|
49
|
+
# FeedValidator
|
50
|
+
@message = options[:text] unless @message
|
51
|
+
@message_count = options[:message_count]
|
52
|
+
@element = options[:element]
|
53
|
+
@parent = options[:parent]
|
54
|
+
@value = options[:value]
|
55
|
+
|
56
|
+
# CSSValidator
|
57
|
+
@level = options[:level]
|
58
|
+
end
|
59
|
+
|
60
|
+
def is_warning?
|
61
|
+
@type == :warning
|
62
|
+
end
|
63
|
+
|
64
|
+
def is_error?
|
65
|
+
@type == :error
|
66
|
+
end
|
67
|
+
|
68
|
+
# Return the message as a string.
|
69
|
+
def to_s
|
70
|
+
str = @type.to_s.upcase
|
71
|
+
if @uri and not @uri.empty?
|
72
|
+
str << "; URI: #{@uri}"
|
73
|
+
end
|
74
|
+
str << "; line #{@line}"
|
75
|
+
if @message and not @message.empty?
|
76
|
+
str << ": #{@message}"
|
77
|
+
end
|
78
|
+
return str
|
79
|
+
end
|
80
|
+
|
81
|
+
end
|
82
|
+
end
|
@@ -0,0 +1,62 @@
|
|
1
|
+
module W3CValidators
|
2
|
+
class Results
|
3
|
+
attr_reader :uri, :checked_by, :doctype, :css_level, :charset, :validity, :debug_messages
|
4
|
+
|
5
|
+
def initialize(options = {})
|
6
|
+
@messages = []
|
7
|
+
@uri = options[:uri]
|
8
|
+
@checked_by = options[:checked_by]
|
9
|
+
@doctype = options[:doctype]
|
10
|
+
@css_level = options[:css_level]
|
11
|
+
@charset = options[:charset]
|
12
|
+
if options[:validity].kind_of?(String)
|
13
|
+
@validity = options[:validity].downcase.strip == 'true'
|
14
|
+
else
|
15
|
+
@validity = options[:validity]
|
16
|
+
end
|
17
|
+
@debug_messages = {}
|
18
|
+
end
|
19
|
+
|
20
|
+
def add_message(type, params = {})
|
21
|
+
uri = params[:uri] ||= @uri
|
22
|
+
@messages << Message.new(uri, type, params)
|
23
|
+
end
|
24
|
+
|
25
|
+
def add_error(params = {})
|
26
|
+
add_message(:error, params)
|
27
|
+
end
|
28
|
+
|
29
|
+
def add_warning(params = {})
|
30
|
+
add_message(:warning, params)
|
31
|
+
end
|
32
|
+
|
33
|
+
def add_debug_message(key, val)
|
34
|
+
@debug_messages[key] = val
|
35
|
+
end
|
36
|
+
|
37
|
+
# Returns either the +DOCTYPE+ or CSS level, whichever is present.
|
38
|
+
def checked_against
|
39
|
+
return @doctype if @doctype
|
40
|
+
return @css_level if @css_level
|
41
|
+
nil
|
42
|
+
end
|
43
|
+
|
44
|
+
def is_valid?
|
45
|
+
@validity
|
46
|
+
end
|
47
|
+
|
48
|
+
# Returns an array of Message objects.
|
49
|
+
def errors
|
50
|
+
errors = []
|
51
|
+
@messages.each { |msg| errors << msg if msg.is_error? }
|
52
|
+
errors
|
53
|
+
end
|
54
|
+
|
55
|
+
# Returns an array of Message objects.
|
56
|
+
def warnings
|
57
|
+
errors = []
|
58
|
+
@messages.each { |msg| errors << msg if msg.is_warning? }
|
59
|
+
errors
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
@@ -0,0 +1,157 @@
|
|
1
|
+
require 'cgi'
|
2
|
+
require 'net/http'
|
3
|
+
require 'uri'
|
4
|
+
require 'rexml/document'
|
5
|
+
|
6
|
+
require 'w3c_validators/exceptions'
|
7
|
+
require 'w3c_validators/constants'
|
8
|
+
require 'w3c_validators/results'
|
9
|
+
require 'w3c_validators/message'
|
10
|
+
|
11
|
+
module W3CValidators
|
12
|
+
# Base class for MarkupValidator and FeedValidator.
|
13
|
+
class Validator
|
14
|
+
VERSION = '0.9.3'
|
15
|
+
USER_AGENT = "Ruby W3C Validators/#{Validator::VERSION} (http://code.dunae.ca/w3c_validators/)"
|
16
|
+
HEAD_STATUS_HEADER = 'X-W3C-Validator-Status'
|
17
|
+
HEAD_ERROR_COUNT_HEADER = 'X-W3C-Validator-Errors'
|
18
|
+
SOAP_OUTPUT_PARAM = 'soap12'
|
19
|
+
|
20
|
+
attr_reader :results, :validator_uri
|
21
|
+
|
22
|
+
# Create a new instance of the Validator.
|
23
|
+
def initialize(options = {})
|
24
|
+
@options = options
|
25
|
+
end
|
26
|
+
|
27
|
+
protected
|
28
|
+
# Perform a validation request.
|
29
|
+
#
|
30
|
+
# +request_mode+ must be either <tt>:get</tt>, <tt>:head</tt> or <tt>:post</tt>.
|
31
|
+
#
|
32
|
+
# Returns Net::HTTPResponse.
|
33
|
+
def send_request(options, request_mode = :get)
|
34
|
+
response = nil
|
35
|
+
results = nil
|
36
|
+
|
37
|
+
Net::HTTP.start(@validator_uri.host, @validator_uri.port) do |http|
|
38
|
+
case request_mode
|
39
|
+
when :head
|
40
|
+
# perform a HEAD request
|
41
|
+
raise ArgumentError, "a URI must be provided for HEAD requests." unless options[:uri]
|
42
|
+
query = create_query_string_data(options)
|
43
|
+
response = http.request_head(@validator_uri.path + '?' + query)
|
44
|
+
when :get
|
45
|
+
# send a GET request
|
46
|
+
query = create_query_string_data(options)
|
47
|
+
response = http.get(@validator_uri.path + '?' + query)
|
48
|
+
when :post
|
49
|
+
# send a multipart form request
|
50
|
+
query, boundary = create_multipart_data(options)
|
51
|
+
response = http.post2(@validator_uri.path, query, "Content-type" => "multipart/form-data; boundary=" + boundary)
|
52
|
+
else
|
53
|
+
raise ArgumentError, "request_mode must be either :get, :head or :post"
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
response.value
|
58
|
+
return response
|
59
|
+
|
60
|
+
rescue Exception => e
|
61
|
+
handle_exception e
|
62
|
+
end
|
63
|
+
|
64
|
+
def create_multipart_data(options) # :nodoc:
|
65
|
+
boundary = '349832898984244898448024464570528145'
|
66
|
+
|
67
|
+
# added 2008-03-12: HTML5 validator expects 'file' and 'content' to be the last fields so
|
68
|
+
# we process those params separately
|
69
|
+
last_params = []
|
70
|
+
|
71
|
+
# added 2008-03-12: HTML5 validator expects 'file' instead of 'uploaded_file'
|
72
|
+
if options[:file] and !options[:uploaded_file]
|
73
|
+
options[:uploaded_file] = options[:file]
|
74
|
+
end
|
75
|
+
|
76
|
+
if options[:uploaded_file]
|
77
|
+
filename = options[:file_path] ||= 'temp.html'
|
78
|
+
content = options[:uploaded_file]
|
79
|
+
last_params << "Content-Disposition: form-data; name=\"uploaded_file\"; filename=\"#{filename}\"\r\n" + "Content-Type: text/html\r\n" + "\r\n" + "#{content}\r\n"
|
80
|
+
options.delete(:uploaded_file)
|
81
|
+
options.delete(:file_path)
|
82
|
+
end
|
83
|
+
|
84
|
+
if options[:content]
|
85
|
+
last_params << "Content-Disposition: form-data; name=\"#{CGI::escape('content')}\"\r\n" + "\r\n" + "#{options[:content]}\r\n"
|
86
|
+
end
|
87
|
+
|
88
|
+
misc_params = []
|
89
|
+
options.each do |key, value|
|
90
|
+
if value
|
91
|
+
misc_params << "Content-Disposition: form-data; name=\"#{CGI::escape(key.to_s)}\"\r\n" + "\r\n" + "#{value}\r\n"
|
92
|
+
end
|
93
|
+
end
|
94
|
+
|
95
|
+
params = misc_params + last_params
|
96
|
+
|
97
|
+
multipart_query = params.collect {|p| '--' + boundary + "\r\n" + p}.join('') + "--" + boundary + "--\r\n"
|
98
|
+
|
99
|
+
[multipart_query, boundary]
|
100
|
+
end
|
101
|
+
|
102
|
+
def create_query_string_data(options) # :nodoc:
|
103
|
+
qs = ''
|
104
|
+
options.each do |key, value|
|
105
|
+
if value
|
106
|
+
qs += "#{key}=" + CGI::escape(value.to_s) + "&"
|
107
|
+
end
|
108
|
+
end
|
109
|
+
qs
|
110
|
+
end
|
111
|
+
|
112
|
+
def read_local_file(file_path) # :nodoc:
|
113
|
+
IO.read(file_path)
|
114
|
+
end
|
115
|
+
|
116
|
+
private
|
117
|
+
#--
|
118
|
+
# Big thanks to ara.t.howard and Joel VanderWerf on Ruby-Talk for the exception handling help.
|
119
|
+
#++
|
120
|
+
def handle_exception(e, msg = '') # :nodoc:
|
121
|
+
case e
|
122
|
+
when Net::HTTPServerException, SocketError
|
123
|
+
msg = "unable to connect to the validator at #{@validator_uri} (response was #{e.message})."
|
124
|
+
raise ValidatorUnavailable, msg, caller
|
125
|
+
when REXML::ParseException
|
126
|
+
msg = "unable to parse the response from the validator."
|
127
|
+
raise ParsingError, msg, caller
|
128
|
+
else
|
129
|
+
raise e
|
130
|
+
end
|
131
|
+
|
132
|
+
if e.respond_to?(:error_handler_before)
|
133
|
+
fcall(e, :error_handler_before, self)
|
134
|
+
end
|
135
|
+
|
136
|
+
if e.respond_to?(:error_handler_instead)
|
137
|
+
fcall(e, :error_handler_instead, self)
|
138
|
+
else
|
139
|
+
if e.respond_to? :status
|
140
|
+
exit_status(( e.status ))
|
141
|
+
end
|
142
|
+
|
143
|
+
if SystemExit === e
|
144
|
+
stderr.puts e.message unless(SystemExit === e and e.message.to_s == 'exit') ### avoids double message for abort('message')
|
145
|
+
end
|
146
|
+
end
|
147
|
+
|
148
|
+
if e.respond_to?(:error_handler_after)
|
149
|
+
fcall(e, :error_handler_after, self)
|
150
|
+
end
|
151
|
+
|
152
|
+
exit_status(( exit_failure )) if exit_status == exit_success
|
153
|
+
exit_status(( Integer(exit_status) rescue(exit_status ? 0 : 1) ))
|
154
|
+
exit exit_status
|
155
|
+
end
|
156
|
+
end
|
157
|
+
end
|
@@ -0,0 +1,53 @@
|
|
1
|
+
require 'rake'
|
2
|
+
require 'rake/testtask'
|
3
|
+
require 'rake/rdoctask'
|
4
|
+
require 'rake/gempackagetask'
|
5
|
+
require 'lib/w3c_validators'
|
6
|
+
require 'fileutils'
|
7
|
+
|
8
|
+
include W3CValidators
|
9
|
+
|
10
|
+
desc 'Run the unit tests.'
|
11
|
+
Rake::TestTask.new do |t|
|
12
|
+
t.libs << 'lib'
|
13
|
+
t.libs << 'lib/test'
|
14
|
+
t.test_files = FileList['test/test*.rb'].exclude('test_helper.rb')
|
15
|
+
t.verbose = false
|
16
|
+
end
|
17
|
+
|
18
|
+
|
19
|
+
desc 'Generate documentation for W3C Validators.'
|
20
|
+
Rake::RDocTask.new(:rdoc) do |rdoc|
|
21
|
+
rdoc.rdoc_dir = 'doc'
|
22
|
+
rdoc.title = 'Ruby W3C Validators'
|
23
|
+
rdoc.options << '--all' << '--inline-source' << '--line-numbers'
|
24
|
+
rdoc.rdoc_files.include('README')
|
25
|
+
rdoc.rdoc_files.include('LICENSE')
|
26
|
+
rdoc.rdoc_files.include('CHANGELOG')
|
27
|
+
rdoc.rdoc_files.include('lib/*.rb')
|
28
|
+
rdoc.rdoc_files.include('lib/w3c_validators/*.rb')
|
29
|
+
end
|
30
|
+
|
31
|
+
|
32
|
+
spec = Gem::Specification.new do |s|
|
33
|
+
s.name = "w3c_validators"
|
34
|
+
s.version = "0.9.3"
|
35
|
+
s.author = "Alex Dunae"
|
36
|
+
s.homepage = "http://code.dunae.ca/w3c_validators"
|
37
|
+
s.platform = Gem::Platform::RUBY
|
38
|
+
s.description = <<-EOF
|
39
|
+
W3C Validators is a Ruby wrapper for the World Wide Web Consortium's online validation services.
|
40
|
+
EOF
|
41
|
+
s.summary = "Wrapper for the World Wide Web Consortium's online validation services."
|
42
|
+
s.files = FileList["{lib}/**/*"].to_a
|
43
|
+
s.test_files = Dir.glob('test/test_*.rb')
|
44
|
+
s.has_rdoc = true
|
45
|
+
s.extra_rdoc_files = ["README", "LICENSE", "CHANGELOG"]
|
46
|
+
s.rdoc_options << '--all' << '--inline-source' << '--line-numbers'
|
47
|
+
end
|
48
|
+
|
49
|
+
desc 'Build the W3C Validators gem.'
|
50
|
+
Rake::GemPackageTask.new(spec) do |pkg|
|
51
|
+
pkg.need_zip = true
|
52
|
+
pkg.need_tar = true
|
53
|
+
end
|
@@ -0,0 +1,10 @@
|
|
1
|
+
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
|
2
|
+
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
3
|
+
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en" debug="true">
|
4
|
+
<head>
|
5
|
+
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
6
|
+
</head>
|
7
|
+
<body>
|
8
|
+
<p class="desc">Here I�m just testing the features of WeGame, and I have to say.. It beats Fraps on all levels. It�s FPS rate is higher than Fraps while recording, it has a smaller ingame...</p>
|
9
|
+
</body>
|
10
|
+
</html>
|
@@ -0,0 +1,19 @@
|
|
1
|
+
<?xml version="1.0" encoding="utf-8"?>
|
2
|
+
<feed xmlns="http://www.w3.org/2005/Atom">
|
3
|
+
<title>Example Feed</title>
|
4
|
+
<subtitle>A subtitle.</subtitle>
|
5
|
+
<link href="http://example.org/feed/" rel="self"/>
|
6
|
+
<link href="http://example.org/"/>
|
7
|
+
<updated>2003-12-13T18:30:02Z</updated>
|
8
|
+
<author>
|
9
|
+
<email>johndoe@example.com</email>
|
10
|
+
</author>
|
11
|
+
<id>urn:uuid:60a76c80-d399-11d9-b91C-0003939e0af6</id>
|
12
|
+
<entry>
|
13
|
+
<title>Atom-Powered Robots Run Amok</title>
|
14
|
+
<link href="http://example.org/2003/12/13/atom03"/>
|
15
|
+
<id>urn:uuid:1225c695-cfb8-4ebb-aaaa-80da344efa6a</id>
|
16
|
+
<updated>2003-12-13T18:30:02Z</updated>
|
17
|
+
<summary>Some text.</summary>
|
18
|
+
</entry>
|
19
|
+
</feed>
|
@@ -0,0 +1,16 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
<html lang="en-ca">
|
3
|
+
<head>
|
4
|
+
<!--<meta http-equiv="Content-type" content="text/html; charset=iso-8859-1">-->
|
5
|
+
<title>HTML 5 Example</title>
|
6
|
+
</head>
|
7
|
+
<body>
|
8
|
+
<!-- should have one error (missing </section>) and one warning (no content type) -->
|
9
|
+
<p>This is a sample HTML 5 document.</p>
|
10
|
+
<section>
|
11
|
+
<h1>Example of paragraphs</h1>
|
12
|
+
This is the <em>first</em> paragraph in this example.
|
13
|
+
<p>This is the second.</p>
|
14
|
+
<p>Test<br>test</p>
|
15
|
+
</body>
|
16
|
+
</html>
|
@@ -0,0 +1,11 @@
|
|
1
|
+
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
2
|
+
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en-ca" lang="en-ca">
|
3
|
+
<head>
|
4
|
+
<meta http-equiv="Content-type" content="text/html; charset=utf-8" />
|
5
|
+
<title>W3C Validators -- Invalid Test Page </title>
|
6
|
+
</head>
|
7
|
+
<body>
|
8
|
+
<p unknown="true">Invalid!</p>
|
9
|
+
<!-- 1 error; 0 warnings -->
|
10
|
+
</body>
|
11
|
+
</html>
|
@@ -0,0 +1,20 @@
|
|
1
|
+
<?xml version="1.0" encoding="utf-8"?>
|
2
|
+
<feed xmlns="http://www.w3.org/2005/Atom">
|
3
|
+
<title>Example Feed</title>
|
4
|
+
<subtitle>A subtitle.</subtitle>
|
5
|
+
<link href="http://example.org/feed/" rel="self"/>
|
6
|
+
<link href="http://example.org/"/>
|
7
|
+
<updated>2003-12-13T18:30:02Z</updated>
|
8
|
+
<author>
|
9
|
+
<name>John Doe</name>
|
10
|
+
<email>johndoe@example.com</email>
|
11
|
+
</author>
|
12
|
+
<id>urn:uuid:60a76c80-d399-11d9-b91C-0003939e0af6</id>
|
13
|
+
<entry>
|
14
|
+
<title>Atom-Powered Robots Run Amok</title>
|
15
|
+
<link href="http://example.org/2003/12/13/atom03"/>
|
16
|
+
<id>urn:uuid:1225c695-cfb8-4ebb-aaaa-80da344efa6a</id>
|
17
|
+
<updated>2003-12-13T18:30:02Z</updated>
|
18
|
+
<summary>Some text.</summary>
|
19
|
+
</entry>
|
20
|
+
</feed>
|
@@ -0,0 +1,16 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
<html lang="en-ca">
|
3
|
+
<head>
|
4
|
+
<meta http-equiv="Content-type" content="text/html; charset=iso-8859-1">
|
5
|
+
<title>HTML 5 Example</title>
|
6
|
+
</head>
|
7
|
+
<body>
|
8
|
+
<p>This is a sample HTML 5 document.</p>
|
9
|
+
<section>
|
10
|
+
<h1>Example of paragraphs</h1>
|
11
|
+
This is the <em>first</em> paragraph in this example.
|
12
|
+
<p>This is the second.</p>
|
13
|
+
<!-- This is not a paragraph. -->
|
14
|
+
</section>
|
15
|
+
</body>
|
16
|
+
</html>
|
@@ -0,0 +1,11 @@
|
|
1
|
+
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
2
|
+
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en-ca" lang="en-ca">
|
3
|
+
<head>
|
4
|
+
<meta http-equiv="Content-type" content="text/html; charset=utf-8" />
|
5
|
+
<title>W3C Validators -- Valid Test Page </title>
|
6
|
+
</head>
|
7
|
+
<body>
|
8
|
+
<p>Valid!</p>
|
9
|
+
<!-- 0 errors; 0 warnings -->
|
10
|
+
</body>
|
11
|
+
</html>
|
@@ -0,0 +1,51 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/test_helper'
|
2
|
+
|
3
|
+
# Test cases for the CSSValidator.
|
4
|
+
class CSSValidatorTests < Test::Unit::TestCase
|
5
|
+
include W3CValidators
|
6
|
+
def setup
|
7
|
+
@v = CSSValidator.new
|
8
|
+
|
9
|
+
@invalid_fragment = <<-EOT
|
10
|
+
a { color: white; }
|
11
|
+
body { margin: blue; }
|
12
|
+
|
13
|
+
EOT
|
14
|
+
|
15
|
+
sleep 1
|
16
|
+
end
|
17
|
+
|
18
|
+
def test_overriding_css_profile
|
19
|
+
@v.set_profile!(:svgbasic)
|
20
|
+
r = @v.validate_text(@invalid_fragment)
|
21
|
+
assert_equal 'svgbasic', r.css_level
|
22
|
+
end
|
23
|
+
|
24
|
+
def test_validating_file
|
25
|
+
file_path = File.expand_path(File.dirname(__FILE__) + '/fixtures/invalid_css.css')
|
26
|
+
r = @v.validate_file(file_path)
|
27
|
+
assert_equal 1, r.errors.length
|
28
|
+
end
|
29
|
+
|
30
|
+
def test_validating_uri
|
31
|
+
@v.set_profile!(:svgbasic)
|
32
|
+
r = @v.validate_text(@invalid_fragment)
|
33
|
+
assert_equal 1, r.errors.length
|
34
|
+
end
|
35
|
+
|
36
|
+
def test_validating_text
|
37
|
+
r = @v.validate_text(@invalid_fragment)
|
38
|
+
assert_equal 1, r.errors.length
|
39
|
+
end
|
40
|
+
|
41
|
+
def test_validating_text_via_file
|
42
|
+
file_path = File.expand_path(File.dirname(__FILE__) + '/fixtures/invalid_css.css')
|
43
|
+
fh = File.new(file_path, 'r+')
|
44
|
+
r = @v.validate_file(fh)
|
45
|
+
fh.close
|
46
|
+
assert_equal 1, r.errors.length
|
47
|
+
end
|
48
|
+
|
49
|
+
|
50
|
+
|
51
|
+
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/test_helper'
|
2
|
+
|
3
|
+
class ExceptionTests < Test::Unit::TestCase
|
4
|
+
include W3CValidators
|
5
|
+
|
6
|
+
def setup
|
7
|
+
@valid_fragment = <<-EOV
|
8
|
+
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
|
9
|
+
<title>Test</title>
|
10
|
+
<body>
|
11
|
+
<div class="example">This is a test</div>
|
12
|
+
</body>
|
13
|
+
EOV
|
14
|
+
end
|
15
|
+
|
16
|
+
def test_bad_validator_uri
|
17
|
+
['http://noexist/', 'http://noexist.badtld/',
|
18
|
+
'http://example.com/noexist'].each do |uri|
|
19
|
+
v = MarkupValidator.new(:validator_uri => uri)
|
20
|
+
assert_raise ValidatorUnavailable do
|
21
|
+
r = v.validate_text(@valid_fragment)
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
def test_bad_soap_response
|
27
|
+
return # need to set up a test host
|
28
|
+
[].each do |uri|
|
29
|
+
v = MarkupValidator.new(:validator_uri => uri)
|
30
|
+
assert_raise ParsingError do
|
31
|
+
r = v.validate_text(@valid_fragment)
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
@@ -0,0 +1,61 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/test_helper'
|
2
|
+
|
3
|
+
# Test cases for the FeedValidator.
|
4
|
+
class FeedValidatorTests < Test::Unit::TestCase
|
5
|
+
include W3CValidators
|
6
|
+
def setup
|
7
|
+
@v = FeedValidator.new
|
8
|
+
sleep 1
|
9
|
+
end
|
10
|
+
|
11
|
+
def test_validating_uri_with_soap
|
12
|
+
r = @v.validate_uri('http://code.dunae.ca/w3c_validators/test/invalid_feed.xml')
|
13
|
+
assert_equal 1, r.errors.length
|
14
|
+
assert_equal 1, r.warnings.length
|
15
|
+
end
|
16
|
+
|
17
|
+
def test_validating_file
|
18
|
+
file_path = File.expand_path(File.dirname(__FILE__) + '/fixtures/invalid_feed.xml')
|
19
|
+
r = @v.validate_file(file_path)
|
20
|
+
assert_equal 1, r.errors.length
|
21
|
+
end
|
22
|
+
|
23
|
+
def test_validating_text
|
24
|
+
fragment = <<-EOT
|
25
|
+
<?xml version="1.0" encoding="utf-8"?>
|
26
|
+
<feed xmlns="http://www.w3.org/2005/Atom">
|
27
|
+
<title>Example Feed</title>
|
28
|
+
<subtitle>A subtitle.</subtitle>
|
29
|
+
<link href="http://example.org/feed/" rel="self"/>
|
30
|
+
<link href="http://example.org/"/>
|
31
|
+
<updated>2003-12-13T18:30:02Z</updated>
|
32
|
+
<author>
|
33
|
+
<email>johndoe@example.com</email>
|
34
|
+
</author>
|
35
|
+
<id>urn:uuid:60a76c80-d399-11d9-b91C-0003939e0af6</id>
|
36
|
+
<entry>
|
37
|
+
<title>Atom-Powered Robots Run Amok</title>
|
38
|
+
<link href="http://example.org/2003/12/13/atom03"/>
|
39
|
+
<id>urn:uuid:1225c695-cfb8-4ebb-aaaa-80da344efa6a</id>
|
40
|
+
<updated>2003-12-13T18:30:02Z</updated>
|
41
|
+
<summary>Some text.</summary>
|
42
|
+
</entry>
|
43
|
+
</feed>
|
44
|
+
EOT
|
45
|
+
|
46
|
+
r = @v.validate_text(fragment)
|
47
|
+
assert_equal 1, r.errors.length
|
48
|
+
end
|
49
|
+
|
50
|
+
|
51
|
+
def test_validating_text_via_file
|
52
|
+
file_path = File.expand_path(File.dirname(__FILE__) + '/fixtures/invalid_feed.xml')
|
53
|
+
fh = File.new(file_path, 'r+')
|
54
|
+
r = @v.validate_file(fh)
|
55
|
+
fh.close
|
56
|
+
assert_equal 1, r.errors.length
|
57
|
+
end
|
58
|
+
|
59
|
+
|
60
|
+
|
61
|
+
end
|