[PATCH v2 wayland] protocol: validate the protocol against a dtd

Kristian Høgsberg hoegsberg at gmail.com
Fri Oct 25 19:59:27 CEST 2013


On Wed, Oct 23, 2013 at 02:56:04PM +1000, Peter Hutterer wrote:
> The scanner is not very forgiving if the protocol doesn't match it's
> expectations and crashes without much of a notice. Thus, validate the protocol
> against a DTD.
> 
> Move the protocol subdir forward so we validate first before trying anything
> else, and install the DTD so we can validate weston's protocols as well.
> ---
> First time this didn't get any reactions.
> Changes to v1:
> - create .xml.valid files to only run xmllint when needed
> - rebased to master

Sorry, was busy with the 1.3 release the first time you sent these
out.  Having a DTD is good and I'm fine with xmllint, but I'd like to
also fix any crashes we hit in the scanner.

Both patches applied, thanks.
Kristian

>  Makefile.am          |  2 +-
>  configure.ac         |  3 +++
>  protocol/Makefile.am | 15 ++++++++++++++-
>  protocol/wayland.dtd | 29 +++++++++++++++++++++++++++++
>  4 files changed, 47 insertions(+), 2 deletions(-)
>  create mode 100644 protocol/wayland.dtd
> 
> diff --git a/Makefile.am b/Makefile.am
> index ddf39d1..99607b0 100644
> --- a/Makefile.am
> +++ b/Makefile.am
> @@ -2,7 +2,7 @@ if BUILD_DOCS
>  doc_subdir = doc
>  endif
>  
> -SUBDIRS = src protocol $(doc_subdir) tests cursor
> +SUBDIRS = protocol src $(doc_subdir) tests cursor
>  
>  ACLOCAL_AMFLAGS = -I m4 ${ACLOCAL_FLAGS}
>  
> diff --git a/configure.ac b/configure.ac
> index fa924ae..7b3787f 100644
> --- a/configure.ac
> +++ b/configure.ac
> @@ -87,6 +87,9 @@ fi
>  AC_PATH_PROG(XSLTPROC, xsltproc)
>  AM_CONDITIONAL([HAVE_XSLTPROC], [test "x$XSLTPROC" != "x"])
>  
> +AC_PATH_PROG(XMLLINT, xmllint)
> +AM_CONDITIONAL([HAVE_XMLLINT], [test "x$XMLLINT" != "x"])
> +
>  AC_MSG_CHECKING([for docbook manpages stylesheet])
>  MANPAGES_STYLESHEET=http://docbook.sourceforge.net/release/xsl/current/manpages/docbook.xsl
>  AC_PATH_PROGS_FEATURE_CHECK([XSLTPROC_TMP], [xsltproc],
> diff --git a/protocol/Makefile.am b/protocol/Makefile.am
> index cc9cd1c..e8b6290 100644
> --- a/protocol/Makefile.am
> +++ b/protocol/Makefile.am
> @@ -1 +1,14 @@
> -dist_pkgdata_DATA = wayland.xml
> +dist_pkgdata_DATA = wayland.xml wayland.dtd
> +
> +if HAVE_XMLLINT
> +.PHONY: validate
> +
> +.%.xml.valid: %.xml
> +	$(AM_V_GEN)$(XMLLINT) --noout --dtdvalid $(srcdir)/wayland.dtd $^ > $@
> +
> +validate: .wayland.xml.valid
> +
> +all-local: validate
> +
> +CLEANFILES = .wayland.xml.valid
> +endif
> diff --git a/protocol/wayland.dtd b/protocol/wayland.dtd
> new file mode 100644
> index 0000000..b8b1573
> --- /dev/null
> +++ b/protocol/wayland.dtd
> @@ -0,0 +1,29 @@
> +<!ELEMENT protocol (copyright?, interface+)>
> +  <!ATTLIST protocol name CDATA #REQUIRED>
> +<!ELEMENT copyright (#PCDATA)>
> +<!ELEMENT interface (description?,(request|event|enum)+)>
> +  <!ATTLIST interface name CDATA #REQUIRED>
> +  <!ATTLIST interface version CDATA #REQUIRED>
> +<!ELEMENT request (description?,arg*)>
> +  <!ATTLIST request name CDATA #REQUIRED>
> +  <!ATTLIST request type CDATA #IMPLIED>
> +  <!ATTLIST request since CDATA #IMPLIED>
> +<!ELEMENT event (description?,arg*)>
> +  <!ATTLIST event name CDATA #REQUIRED>
> +  <!ATTLIST event since CDATA #IMPLIED>
> +<!ELEMENT enum (description?,entry*)>
> +  <!ATTLIST enum name CDATA #REQUIRED>
> +  <!ATTLIST enum since CDATA #IMPLIED>
> +<!ELEMENT entry (description?)>
> +  <!ATTLIST entry name CDATA #REQUIRED>
> +  <!ATTLIST entry value CDATA #REQUIRED>
> +  <!ATTLIST entry summary CDATA #IMPLIED>
> +  <!ATTLIST entry since CDATA #IMPLIED>
> +<!ELEMENT arg (description?)>
> +  <!ATTLIST arg name CDATA #REQUIRED>
> +  <!ATTLIST arg type CDATA #REQUIRED>
> +  <!ATTLIST arg summary CDATA #IMPLIED>
> +  <!ATTLIST arg interface CDATA #IMPLIED>
> +  <!ATTLIST arg allow-null CDATA #IMPLIED>
> +<!ELEMENT description (#PCDATA)>
> +  <!ATTLIST description summary CDATA #REQUIRED>
> -- 
> 1.8.3.1
> 
> _______________________________________________
> wayland-devel mailing list
> wayland-devel at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/wayland-devel


More information about the wayland-devel mailing list