From 394218330d06a9af76e8e4125322b1c067c49c1a Mon Sep 17 00:00:00 2001 From: Lucas Cimon Date: Tue, 22 Nov 2016 05:10:00 +0100 Subject: [PATCH 1/7] Bugfix: support for absolute unix-like filepaths under Cygwin - fix: #27 (#28) --- html5validator/validator.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/html5validator/validator.py b/html5validator/validator.py index d188388..306da13 100644 --- a/html5validator/validator.py +++ b/html5validator/validator.py @@ -41,13 +41,16 @@ def __init__(self, directory='.', match='*.html', blacklist=None, '__init__.py', 'vnu.jar' ) if sys.platform == 'cygwin': - self.vnu_jar_location = subprocess.check_output(['cygpath', '-w', self.vnu_jar_location]).strip().decode('utf8') + self.vnu_jar_location = self._cygwin_path_convert(self.vnu_jar_location) def _normalize_string(self, s): s = s.replace('“', '"') s = s.replace('”', '"') return s + def _cygwin_path_convert(self, filepath): + return subprocess.check_output(['cygpath', '-w', filepath]).strip().decode('utf8') + def all_files(self, skip_invisible=True): files = [] for root, dirnames, filenames in os.walk(self.directory): @@ -78,6 +81,9 @@ def validate(self, files=None, errors_only=True, stack_size=None): if not files: files = self.all_files() + if sys.platform == 'cygwin': + files = [self._cygwin_path_convert(f) for f in files] + with open(os.devnull, 'w') as f_null: if subprocess.call(['java', '-version'], stdout=f_null, stderr=f_null) != 0: From 97c617a211da93cdc4df120a9161896f468320fd Mon Sep 17 00:00:00 2001 From: Sven Kreiss Date: Tue, 22 Nov 2016 08:53:40 -0500 Subject: [PATCH 2/7] version 0.2.6 --- html5validator/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/html5validator/__init__.py b/html5validator/__init__.py index 16de63d..8e23aa8 100644 --- a/html5validator/__init__.py +++ b/html5validator/__init__.py @@ -1,5 +1,5 @@ """Validate HTML5 files.""" -__version__ = "0.2.5" +__version__ = "0.2.6" from .validator import Validator, JavaNotFoundException From 6214451192c566938fd7d1fc36f50e3637f50b5f Mon Sep 17 00:00:00 2001 From: Sven Kreiss Date: Sat, 14 Jan 2017 08:38:47 -0500 Subject: [PATCH 3/7] reference localcrawl in doc --- README.rst | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/README.rst b/README.rst index 9b6a9f7..92755c1 100644 --- a/README.rst +++ b/README.rst @@ -1,11 +1,13 @@ HTML5 Validator =============== - This was written with static site generators like `Jekyll `_ - and `Pelican `_ in mind that push to a static - server. ``html5validator`` is a command line executable that integrates - well with CircleCI and TravisCI and tests all static html files for - HTML5 validity. + ``html5validator`` is a command line tool that tests files for + HTML5 validity. This was written with static site generators like + `Jekyll `_ and + `Pelican `_ in mind. Dynamic html content + (for example from JS template engines) can be crawled + (e.g. with `localcrawl `_) + and then validated. .. image:: https://travis-ci.org/svenkreiss/html5validator.svg?branch=master :target: https://travis-ci.org/svenkreiss/html5validator From 20d70391ba80f93a8de21d5856e2dc4a5aaf574a Mon Sep 17 00:00:00 2001 From: Sven Kreiss Date: Sat, 14 Jan 2017 09:01:56 -0500 Subject: [PATCH 4/7] init Python 3.6 (#29) --- .travis.yml | 1 + README.rst | 2 +- setup.py | 1 + 3 files changed, 3 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 7eb3036..030ffa4 100644 --- a/.travis.yml +++ b/.travis.yml @@ -3,6 +3,7 @@ python: - "2.7" - "3.4" - "3.5" + - "3.6" - "pypy" - "pypy3" diff --git a/README.rst b/README.rst index 92755c1..195f896 100644 --- a/README.rst +++ b/README.rst @@ -18,7 +18,7 @@ HTML5 Validator Install ------- -This module requires Python 2.7, 3.4 or 3.5 and Java 8. +This module requires Python 2.7, 3.4, 3.5 or 3.6 and Java 8. Install with ``pip install html5validator`` and run with .. code-block:: bash diff --git a/setup.py b/setup.py index ed78982..b2ed575 100644 --- a/setup.py +++ b/setup.py @@ -63,6 +63,7 @@ 'Programming Language :: Python :: 2.7', 'Programming Language :: Python :: 3.4', 'Programming Language :: Python :: 3.5', + 'Programming Language :: Python :: 3.6', 'Programming Language :: Python :: Implementation :: PyPy', ] ) From 53c28315c0a7c6c03a942fe613f3391d6eb904b7 Mon Sep 17 00:00:00 2001 From: Sven Kreiss Date: Sun, 9 Apr 2017 22:09:01 -0400 Subject: [PATCH 5/7] update vnu.jar to 17.3.0 (#31) * update vnu.jar to 17.3.0 * lint --- .travis.yml | 2 +- html5validator/__init__.py | 1 + html5validator/cli.py | 14 ++-- html5validator/validator.py | 12 +-- setup.cfg | 3 + setup.py | 13 +-- tests/test_simple.py | 14 +++- vnujar/CHANGELOG.md | 90 +++++++++++++++++++++ vnujar/README.md | 156 +++++++++++++++++++++++------------- vnujar/index.html | 105 ++++++++++++++++++------ vnujar/vnu.jar | Bin 23485341 -> 25642336 bytes 11 files changed, 305 insertions(+), 105 deletions(-) create mode 100644 setup.cfg diff --git a/.travis.yml b/.travis.yml index 030ffa4..b0ccab2 100644 --- a/.travis.yml +++ b/.travis.yml @@ -16,4 +16,4 @@ before_install: install: - "pip install .[tests]" -script: nosetests -vv +script: flake8 && nosetests -vv diff --git a/html5validator/__init__.py b/html5validator/__init__.py index 8e23aa8..5479a90 100644 --- a/html5validator/__init__.py +++ b/html5validator/__init__.py @@ -1,4 +1,5 @@ """Validate HTML5 files.""" +# flake8: noqa __version__ = "0.2.6" diff --git a/html5validator/cli.py b/html5validator/cli.py index f8cd541..a361052 100644 --- a/html5validator/cli.py +++ b/html5validator/cli.py @@ -3,19 +3,21 @@ from __future__ import unicode_literals -import sys -import logging +from .validator import Validator import argparse +import logging +import sys -from .validator import Validator from . import __version__ as VERSION LOGGER = logging.getLogger(__name__) def main(): - parser = argparse.ArgumentParser(description='[v'+VERSION+'] '+__doc__, - prog='html5validator') + parser = argparse.ArgumentParser( + description='[v' + VERSION + '] ' + __doc__, + prog='html5validator' + ) parser.add_argument('--root', default='.', help='start directory to search for files to validate') parser.add_argument('--match', default='*.html', @@ -52,7 +54,7 @@ def main(): help=('log level: DEBUG, INFO or WARNING ' '(default: WARNING)')) parser.add_argument('--version', action='version', - version='%(prog)s '+VERSION) + version='%(prog)s ' + VERSION) args = parser.parse_args() logging.basicConfig(level=getattr(logging, args.log)) diff --git a/html5validator/validator.py b/html5validator/validator.py index 306da13..f2ae0bf 100644 --- a/html5validator/validator.py +++ b/html5validator/validator.py @@ -3,13 +3,13 @@ from __future__ import unicode_literals +import fnmatch +import logging import os import re +import subprocess import sys import vnujar -import fnmatch -import logging -import subprocess LOGGER = logging.getLogger(__name__) @@ -41,7 +41,8 @@ def __init__(self, directory='.', match='*.html', blacklist=None, '__init__.py', 'vnu.jar' ) if sys.platform == 'cygwin': - self.vnu_jar_location = self._cygwin_path_convert(self.vnu_jar_location) + self.vnu_jar_location = self._cygwin_path_convert( + self.vnu_jar_location) def _normalize_string(self, s): s = s.replace('“', '"') @@ -49,7 +50,8 @@ def _normalize_string(self, s): return s def _cygwin_path_convert(self, filepath): - return subprocess.check_output(['cygpath', '-w', filepath]).strip().decode('utf8') + return subprocess.check_output( + ['cygpath', '-w', filepath]).strip().decode('utf8') def all_files(self, skip_invisible=True): files = [] diff --git a/setup.cfg b/setup.cfg new file mode 100644 index 0000000..f95f7dc --- /dev/null +++ b/setup.cfg @@ -0,0 +1,3 @@ +[flake8] +ignore = H301 +exclude = venv*/,docs,build,dist,pypy diff --git a/setup.py b/setup.py index b2ed575..cb9c0f9 100644 --- a/setup.py +++ b/setup.py @@ -3,14 +3,6 @@ import re import sys -# workaround: nosetests don't exit cleanly with older -# python version (<=2.6 and even <2.7.4) -try: - import multiprocessing -except ImportError: - pass - - INSTALL_REQUIRES = [] @@ -41,7 +33,10 @@ install_requires=INSTALL_REQUIRES, extras_require={ - 'tests': ['nose'], + 'tests': [ + 'hacking', + 'nose', + ], }, entry_points={ 'console_scripts': [ diff --git a/tests/test_simple.py b/tests/test_simple.py index b42b1b6..9892cea 100644 --- a/tests/test_simple.py +++ b/tests/test_simple.py @@ -11,10 +11,15 @@ def test_valid(): def test_invalid(): assert subprocess.call(['html5validator', '--root=tests/invalid/']) == 1 + def test_return_value(): - assert subprocess.call(['html5validator', '--root=tests/return_value/', '--match=254.html']) == 254 - assert subprocess.call(['html5validator', '--root=tests/return_value/', '--match=255.html']) == 255 - assert subprocess.call(['html5validator', '--root=tests/return_value/', '--match=256.html']) == 255 + assert subprocess.call(['html5validator', '--root=tests/return_value/', + '--match=254.html']) == 254 + assert subprocess.call(['html5validator', '--root=tests/return_value/', + '--match=255.html']) == 255 + assert subprocess.call(['html5validator', '--root=tests/return_value/', + '--match=256.html']) == 255 + def test_angularjs(): assert subprocess.call([ @@ -36,7 +41,8 @@ def test_multiple_ignoreres(): o = subprocess.call([ 'html5validator', '--root=tests/multiple_ignores/', - '--ignore-re', 'Attribute “ng-[a-z-]+” not allowed', 'Start tag seen without seeing a doctype first', + '--ignore-re', 'Attribute “ng-[a-z-]+” not allowed', + 'Start tag seen without seeing a doctype first', ]) assert o == 0 diff --git a/vnujar/CHANGELOG.md b/vnujar/CHANGELOG.md index 11e35bc..f22b88e 100644 --- a/vnujar/CHANGELOG.md +++ b/vnujar/CHANGELOG.md @@ -2,6 +2,96 @@ With a few exceptions, this is a record of mainly just user-facing changes—that is, either changes to the actual behavior of the checker, or changes to any options/interfaces the checker exposes for developers. +# 17.3.0 +26 March 2017 + - Allow “color” attribute with link[rel="mask-icon"] + - Allow `meta[name]` to have `itemref`/`itemscope`/`itemtype`/`itemid` + - Allow `allow-top-navigation-by-user-activation` in `iframe[sandbox]` + - Stop hiding “sectioning roots” headings in “Heading-level outline” + - Change error for `role=none` with `img[alt=""]` to warning + - Fix from @xfq for longstanding bug in “Show source” behavior in Web UI + - Fix from @xfq for controlling some runtime params for HTTP behavior + - Fix from @zcorpan to drop unneeded warning for `` + - Make “Corrupt GZIP trailer” a non-error + - Add `--asciiquotes` option to vnu.jar command-line checker + - Skip lang detection of elements w/ lang attributes not matching `html[lang]` + - Drop Bulgarian lang detection, to prevent Russian misidentification + - Update Estonian/Catalan lang profiles, to prevent Russian misidentification + - Update ICU4J to 58.2 + +# 17.2.1 +06 February 2017 + - Fix bug in language detector that when running the vnu.jar command-line + checker on a list of documents caused it to sometimes misidentify the + language of the 2nd, 3rd, 4th, etc., documents. The bug also caused the + memory used by the checker to increase as the number of documents + checked at the same time increased, and caused performance to degrade. + - Allow `aria-required` attribute everywhere `required` attribute is allowed + - Add `--exit-zero-always` option to vnu.jar command-line checker + - Fix longstanding bug around code for identifying overlapping cells in + table-integrity checker (the bug somewhat frequently gets hit when checking + Wikipedia pages but otherwise in the wild gets hit only extremely rarely) + +# 17.2.0 +30 January 2017 + - Fix bug that broke vnu.jar command-line checking of URLs + - Fix bug in `rel="shortcut icon"` checking + - Add `nu.client.EmbeddedValidator` for use as library by other Java apps + - Disallow `tfoot` before `tbody` + +# 17.1.0 +15 January 2017 + This release adds the following changes to the vnu.jar command-line + checker that had already been made available in the Web-based checker in + the 17.0.1 release. + - Allow **custom elements** (names containing “-”; e.g., ``) + - Allow anything in `template` element subtrees (exclude from checking) + +# 17.0.1 +08 January 2017 + - New language-detection feature; warns for missing/wrong `html[lang]` + - New option `--no-langdetect` for `vnu.jar` disables language detection + - Allow **custom elements** (names containing “-”; e.g., ``) + - Allow the `is` attribute (for custom elements) + - Allow **ARIA 1.1** roles/states/properties + - Warn for viewport values that restrict resizing + - Allow `div` in `dl`, to group `dt`+`dd` sets + - Allow anything in `template` element subtrees (exclude from checking) + - Allow `link[rel=preload]` in body + - Disallow `sizes` attribute on non-icon `link` + - Allow `` + - Allow comments before doctype (warning dropped) + - Allow `