mirror of
https://git.proxmox.com/git/mirror_novnc
synced 2025-04-28 11:09:24 +00:00
Add exceptions for CSS validator false positives
Some new CSS incorrectly give errors from validator.w3.org. Issues were opened in that repo, so hopefully we can remove these exceptions soon. I searched for alternative validators, but couldn't find a different one that had a simple API like this one. In order to reliably detect & handle these exceptions we unfortunately need to make the validator output parsing quite a bit more complicated.
This commit is contained in:
parent
14f9ea5880
commit
237a34dfb3
@ -28,16 +28,63 @@ for fn in "$@"; do
|
||||
curl --silent \
|
||||
--header "Content-Type: ${type}; charset=utf-8" \
|
||||
--data-binary @${fn} \
|
||||
https://validator.w3.org/nu/?out=text > $OUT
|
||||
cat $OUT
|
||||
echo
|
||||
"https://validator.w3.org/nu/?out=gnu&level=error&asciiquotes=yes" \
|
||||
> $OUT
|
||||
|
||||
# We don't fail the check for warnings as some warnings are
|
||||
# not relevant for us, and we don't currently have a way to
|
||||
# ignore just those
|
||||
if grep -q -s -E "^Error:" $OUT; then
|
||||
while read -r line; do
|
||||
echo
|
||||
|
||||
line_info=$(echo $line | cut -d ":" -f 2)
|
||||
start_info=$(echo $line_info | cut -d "-" -f 1)
|
||||
end_info=$(echo $line_info | cut -d "-" -f 2)
|
||||
|
||||
line_start=$(echo $start_info | cut -d "." -f 1)
|
||||
col_start=$(echo $start_info | cut -d "." -f 2)
|
||||
|
||||
line_end=$(echo $end_info | cut -d "." -f 1)
|
||||
col_end=$(echo $end_info | cut -d "." -f 2)
|
||||
|
||||
error=$(echo $line | cut -d ":" -f 4-)
|
||||
|
||||
case $error in
|
||||
*"\"scrollbar-gutter\": Property \"scrollbar-gutter\" doesn't exist.")
|
||||
# FIXME: https://github.com/validator/validator/issues/1788
|
||||
echo "Ignoring below error on line ${line_start}," \
|
||||
"the scrollbar-gutter property actually exist and is widely" \
|
||||
"supported:"
|
||||
echo $error
|
||||
continue
|
||||
;;
|
||||
*"\"clip-path\": \"path("*)
|
||||
# FIXME: https://github.com/validator/validator/issues/1786
|
||||
echo "Ignoring below error on line ${line_start}," \
|
||||
"the path() function is valid for clip-path and is" \
|
||||
"widely supported:"
|
||||
echo $error
|
||||
continue
|
||||
;;
|
||||
*"Parse Error.")
|
||||
# FIXME: https://github.com/validator/validator/issues/1786
|
||||
lineofselector=$(grep -n "@supports selector(" $fn | cut -d ":" -f 1)
|
||||
linediff=$((lineofselector-line_start))
|
||||
# Only ignore if parse error is within 50 lines of "selector()"
|
||||
if [ ${linediff#-} -lt 50 ]; then
|
||||
echo "Ignoring below error on line ${line_start}," \
|
||||
"the @supports selector() function should not give a parse" \
|
||||
"error:"
|
||||
echo $error
|
||||
continue
|
||||
fi
|
||||
;;
|
||||
esac
|
||||
echo "ERROR between line ${line_start} (col ${col_start})" \
|
||||
"and line ${line_end} (col ${col_end}):"
|
||||
echo $error
|
||||
RET=1
|
||||
fi
|
||||
done < "$OUT"
|
||||
done
|
||||
|
||||
rm $OUT
|
||||
|
Loading…
Reference in New Issue
Block a user