Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Latest commit

 

History

History
History
59 lines (52 loc) · 2.01 KB

File metadata and controls

59 lines (52 loc) · 2.01 KB
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
#!/bin/bash
# Validates rulesets, using both trivial-validate.py (slower, can make more
# complicated assertions) and xmllint with our custom RELAX NG grammar that
# specifies the format of ruleset XML (faster, more limited).
#
# The rulesets sqlite must already have been generated at
# https-everywhere/pkg/rulesets.unvalidated.sqlite.
#
# If validation is successful, that file will be copied to
# https-everywhere/src/defaults/rulesets.sqlite for inclusion in the XPI.
set -o errexit -o pipefail
cd $(dirname $0)
# =============== BEGIN VALIDATION ================
# Unless we're in a hurry, validate the ruleset library & locales
die() {
echo >&2 "ERROR:" "$@"
exit 1
}
INPUT="../pkg/rulesets.unvalidated.sqlite"
if python2.7 trivial-validate.py --quiet --db "$INPUT" >&2
then
echo Validation of included rulesets completed. >&2
echo >&2
else
die "Validation of rulesets failed."
fi
# Check for xmllint.
type xmllint >/dev/null || die "xmllint not available"
GRAMMAR="relaxng.xml"
# xmllint spams stderr with "<FILENAME> validates, even with the --noout flag,
# so we capture only the results that do not contain 'validates'
validate_grammar() {
find ../src/chrome/content/rules -name "*.xml" | \
xargs xmllint --noout --relaxng $GRAMMAR
}
grammar_errors=$(validate_grammar 2>&1 | grep -v "validates" || true)
if [ -z "$grammar_errors" ]
then
echo Validation of rulesets against $GRAMMAR succeeded. >&2
else
echo >&2 "$grammar_errors"
# One very common error is to mess up rule attributes, so we check for
# this explicitly.
if [[ $grammar_errors == *"Element rule failed to validate attributes"* ]]
then
echo "Two very common reasons for this are the following:"
echo "- Missing caret (^) in 'from' attribute: it should be \"^http:\" and not \"http:\"."
echo "- Missing trailing slashes in 'from' or 'to' when specifying full hostnames: it should be \"https://eff.org/\" and not \"https://eff.org\"."
fi
die "Validation of rulesets against $GRAMMAR failed."
fi
cp "$INPUT" ../src/defaults/rulesets.sqlite
Morty Proxy This is a proxified and sanitized view of the page, visit original site.