1
0
mirror of https://gitlab.gnome.org/GNOME/libxml2.git synced 2024-10-26 20:25:14 +03:00
Commit Graph

187 Commits

Author SHA1 Message Date
Maks Mishin
cd94985fb7 relaxng: Remove useless if statement 2024-02-29 01:14:06 +03:00
Nick Wellnhofer
c8f1f4a280 doc: Improve documentation of error handlers 2023-12-21 17:36:17 +01:00
Nick Wellnhofer
531d06add6 error: Stop printing some errors by default
Unfortunately, it's long-standing behavior for libxml2 to print all
reported errors to stderr by default. This default behavior is now
partially disabled. If no error handler is set, only parser and
validation errors are passed to a generic error handler or printed to
stderr. Other errors are still available via xmlGetLastError and can be
captured with a structured error handler.
2023-12-21 15:02:24 +01:00
Nick Wellnhofer
83c6aeef49 relaxng: Improve error handling
Pass RelaxNG structured error handler to XML parser.

Handle malloc failure from xmlRaiseError.

Remove argument from memory error handler.

Use xmlRaiseMemoryError.

Don't use xmlGenericError.

Remove TODO macro.
2023-12-21 15:01:42 +01:00
Nick Wellnhofer
4e1c13ebfd debug: Remove debugging code
This is barely useful these days and only clutters the code base.
2023-09-19 17:35:09 +02:00
Nick Wellnhofer
1eb2ca9f47 relaxng: Remove useless if statement
ctxt and define are non-NULL at this point.

Fixes #482.
2023-02-21 15:46:06 +01:00
Nick Wellnhofer
2cac626976 Don't use sizeof(xmlChar) or sizeof(char) 2022-09-01 03:35:19 +02:00
Nick Wellnhofer
0f568c0b73 Consolidate private header files
Private functions were previously declared

- in header files in the root directory
- in public headers guarded with IN_LIBXML
- in libxml.h
- redundantly in source files that used them.

Consolidate all private header files in include/private.
2022-08-26 02:11:56 +02:00
Nick Wellnhofer
3e7b4f37aa Avoid calling xmlSetTreeDoc
Create text nodes with xmlNewDocText or set the document directly to
avoid xmlSetTreeDoc being called when the node is inserted.
2022-06-20 01:49:39 +02:00
Nick Wellnhofer
2070ade6df Undeprecate schema init functions
These functions aren't called from xmlInitParser, so it's better to keep
them public for now.
2022-03-10 01:24:31 +01:00
Nick Wellnhofer
40483d0ce2 Deprecate module init and cleanup functions
These functions shouldn't be part of the public API. Most init
functions are only thread-safe when called from xmlInitParser. Global
variables should only be cleaned up by calling xmlCleanupParser.
2022-03-06 15:59:43 +01:00
Nick Wellnhofer
346c3a930c Remove elfgcchack.h
The same optimization can be enabled with -fno-semantic-interposition
since GCC 5. clang has always used this option by default.
2022-02-20 21:49:04 +01:00
David King
477f6de394 Fix memory leak in xmlRelaxNGNewDocParserCtxt
Found by Coverity.

https://bugzilla.redhat.com/show_bug.cgi?id=1938806
2022-01-16 14:24:45 +01:00
David King
483de2c21d Fix memory leak in xmlRelaxNGParseData
Found by Coverity.

https://bugzilla.redhat.com/show_bug.cgi?id=1938806
2022-01-16 14:23:46 +01:00
Nick Wellnhofer
20c60886e4 Fix typos
Resolves #133.
2020-03-08 17:41:53 +01:00
Jared Yanovich
2a350ee9b4 Large batch of typo fixes
Closes #109.
2019-09-30 18:04:38 +02:00
Nick Wellnhofer
09b6f8183d Fix potential null deref in xmlRelaxNGParsePatterns
Thanks to Zhongyuan Zhou for the initial patch.
2019-08-25 14:12:34 +02:00
Jan Pokorný
ea695ac0d6 Fix unability to RelaxNG-validate grammar with choice-based name class
Previously, test/relaxng/ambig_name-class2.xml would fail to validate
against test/relaxng/ambig_name-class2.rng:

> test/relaxng/ambig_name-class2.rng:4:
>   element attribute: Relax-NG parser error :
>       Found anyName attribute without oneOrMore ancestor
> Relax-NG schema test/relaxng/ambig_name-class2.rng failed to compile

Signed-off-by: Jan Pokorný <jpokorny@redhat.com>
2019-08-25 13:29:04 +02:00
Jan Pokorný
8074b88179 Fix unability to validate ambiguously constructed interleave for RelaxNG
Previously, test/relaxng/ambig_name-class.xml would fail to validate
for a simple reason -- interleave within "open-name-class" context
is supposed to be fine with whatever else is pending the consumption,
since effectively, it's unrelated from a higher parsing perspective.

Signed-off-by: Jan Pokorný <jpokorny@redhat.com>
2019-08-25 13:29:04 +02:00
Nick Wellnhofer
6348496230 Remove redundant code in xmlRelaxNGValidateState
Closes #70.
2019-07-08 12:28:39 +02:00
Nikolai Weibull
7c4949afab Fix "Problem with data in interleave in RelaxNG validation"
Fixes commit c8e5f958.

https://mail.gnome.org/archives/xml/2018-November/msg00029.html
2019-01-01 20:02:36 +01:00
Nikolai Weibull
c64d4efb31 Remove redefined starts and defines inside include elements
When including a grammar from another grammar, we need to make sure that any
redefines of starts and includes that that grammar does inside any of its
include elements are also removed.
2018-11-29 21:06:06 +01:00
Nikolai Weibull
46da8fc529 Allow choice within choice in nameClass in RELAX NG
The pattern nameClass allows for nested choice elements, for example

  <name>
    <choice>
      <choice>
        <name>a</name>
        <name>b</name>
      </choice>
      <name>c</name>
    </choice>
  </name>

which is semantically equivalent to

  <name>
    <choice>
      <name>a</name>
      <name>b</name>
      <name>c</name>
    </choice>
  </name>

The old code didn’t handle this correctly, as it never expected a choice inside
another choice.  This patch fixes this by flattening any nested choices.

This pattern of nested choice elements comes up in RELAX NG simplification,
where all choice elements are rewritten in this nested manner, see section 4.12
of the RELAX NG specification.
2018-11-29 21:03:11 +01:00
Nikolai Weibull
4338c310eb Look inside divs for starts and defines inside include
RELAX NG allows for div elements inside of include elements.  We need to look
inside those div elements for start and define elements that may be redefining
start and define elements in the included grammar.
2018-11-29 21:00:46 +01:00
Nikolai Weibull
c8e5f9588b Problem with data in interleave in RelaxNG validation
Reported in https://mail.gnome.org/archives/xml/2018-October/msg00003.html

The issue seems to be that we build groups of what can be matched by
the interleave, but that these groups don’t include data, list,
and value elements, only element and text elements.  This patch
extends xmlRelaxNGGetElements so that it can return these elements
for us in xmlRelaxNGComputeInterleaves.  Then we make sure to
updatexmlRelaxNGNodeMatchesList as well so that it accepts the correct
types.
2018-11-22 18:14:47 +01:00
Nick Wellnhofer
e03f0a199a Fix hash callback signatures
Make sure that all parameters and return values of hash callback
functions exactly match the callback function type. This is required
to pass clang's Control Flow Integrity checks and to allow compilation
to asm.js with Emscripten.

Fixes bug 784861.
2017-11-09 16:42:47 +01:00
J. Peter Mugaas
d2c329a9a4 Fix -Wimplicit-fallthrough warnings
Add "falls through" comments to quench implicit-fallthrough warnings
which are enabled by -Wextra under GCC 7.
2017-10-21 13:49:31 +02:00
Nick Wellnhofer
d422b954be Fix pointer/int cast warnings on 64-bit Windows
On 64-bit Windows, `long` is 32 bits wide and can't hold a pointer.
Switch to ptrdiff_t instead which should be the same size as a pointer
on every somewhat sane platform without requiring C99 types like
intptr_t.

Fixes bug 788312.

Thanks to J. Peter Mugaas for the report and initial patch.
2017-10-09 13:47:49 +02:00
Chun-wei Fan
d77e5fc4bc relaxng.c, xmlschemas.c: Fix build on pre-C99 compilers
Make sure that the variables are declared at the top of the block.

https://bugzilla.gnome.org/show_bug.cgi?id=767063
2016-06-23 19:02:26 +08:00
David Kilzer
502f6a6d08 More format string warnings with possible format string vulnerability
For https://bugzilla.gnome.org/show_bug.cgi?id=761029

adds a new xmlEscapeFormatString() function to escape composed format
strings
2016-05-23 15:01:08 +08:00
David Kilzer
4472c3a5a5 Fix some format string warnings with possible format string vulnerability
For https://bugzilla.gnome.org/show_bug.cgi?id=761029

Decorate every method in libxml2 with the appropriate
LIBXML_ATTR_FORMAT(fmt,args) macro and add some cleanups
following the reports.
2016-05-23 15:01:07 +08:00
Daniel Veillard
2fab235d10 Fix support for except in nameclasses
For https://bugzilla.gnome.org/show_bug.cgi?id=565219

The code was imply missing even if simple, added a few regression
tests.
2015-03-16 08:43:37 +08:00
Philip Withnall
579410427f Remove various unused value assignments
As detected by Coverity (CIDs 60467–60472).

https://bugzilla.gnome.org/show_bug.cgi?id=739220
2014-10-27 21:18:57 +08:00
Daniel Veillard
42870f46cc Add couple of missing Null checks
For https://bugzilla.gnome.org/show_bug.cgi?id=733710
Reported by Gaurav but with slightly different fixes
2014-07-26 21:04:54 +08:00
Gaurav Gupta
54c4b1aa71 Add a couple of misisng check in xmlRelaxNGCleanupTree
For https://bugzilla.gnome.org/show_bug.cgi?id=733041

check cur->parent before dereferencing the pointer even if
a null parent there should not happen
Also fix a typo
2014-07-14 16:14:44 +08:00
Gaurav Gupta
7d2e8c950f Add a missing argument check
For https://bugzilla.gnome.org/show_bug.cgi?id=733042

the states argument of xmlRelaxNGAddStates() ought to be checked too
2014-07-14 16:08:28 +08:00
Gaurav Gupta
6d753994b9 Adding a check in case of allocation error
For https://bugzilla.gnome.org/show_bug.cgi?id=733043

There is missing Null condition in xmlRelaxNGValidateInterleave of
relaxng.c
Dereferencing it may cause a crash.
2014-07-14 16:01:10 +08:00
Jan Pokorný
acace88c4a Fix typos in relaxng.c
Signed-off-by: Jan Pokorný <jpokorny@redhat.com>
2014-06-10 14:41:06 +08:00
Shaun McCance
6473a41a49 Implement choice for name classes on attributes
https://bugzilla.gnome.org/show_bug.cgi?id=710744
2013-11-28 16:09:00 +08:00
Gaurav
7d4e259fbf Avoid some dead code and cleanup in relaxng.c
https://bugzilla.gnome.org/show_bug.cgi?id=705388

Code needed a bit of cleanup
2013-09-30 11:27:41 +08:00
Michael Wood
fb27e2cd20 Fix spelling of "length". 2012-10-30 10:18:49 +08:00
Daniel Veillard
f8e3db0445 Big space and tab cleanup
Remove all space before tabs and space and tabs at end of lines.
2012-09-11 13:26:36 +08:00
Daniel Veillard
264cee695a Add a missing element check 2012-08-13 12:40:53 +08:00
Noam
9313ae8517 Fix weird streaming RelaxNG errors
For https://bugzilla.gnome.org/show_bug.cgi?id=512454
The bug was to use compiled determinitic automata when
the content model was found to be non-deterministic, leading
to random parsing errors.
2012-05-15 11:03:46 +08:00
Daniel Veillard
7dd0d916c6 Fix an unimplemented part in RNG value validation
Forgot to implement <optional> this was raised again
in https://bugzilla.redhat.com/show_bug.cgi?id=752393
as this make libxml2 fail to validate against ODF RNGs

Daniel
2011-11-10 18:08:33 +08:00
Shaun McCance
d7eb9b5d47 Fix RELAX NG include bug #655288
When overriding during include, children of the root
node are scanned. But the root node was gotten with
doc->children, instead of xmlDocGetRootElement.
2011-08-04 10:28:59 -04:00
Ben Walton
a7a6a4b2f3 relaxng.c: cast to allow compilation with sun studio 11
Sun Studio 11 was failing to compile relaxng.c due to a type mismatch
in a ternary operator used to provide an argument to xmlRngPErr.  It
seems that sos11 cc is more pedantic about this part of the C99
standard.  GCC issues a warning but doesn't fail by default.

After casting the string literal "nothing" to (const xmlChar *) sos11
cc is happy.  GCC no longer issues a warning either.

Another warning was cleaned up with an identical cast.
2010-03-15 10:06:36 +01:00
Daniel Veillard
aa422d9254 595792 fixing a RelaxNG bug introduced in 2.7.4
* relaxng.c: refs definitions added from inported schemas should not
  be processed as refs from the main schemas
* test/relaxng/595792* result/relaxng/595792*: add the test to the
  regression suite
2009-09-24 11:31:48 +02:00
Rob Richards
848e5cf3ab Fix Windows build
* relaxng.c: fix windows build
2009-09-09 12:13:58 -04:00
Daniel Veillard
594e5dfb48 Chasing dead assignments reported by clang-scan
* SAX2.c dict.c error.c hash.c nanohttp.c parser.c python/libxml.c
  relaxng.c runtest.c tree.c valid.c xinclude.c xmlregexp.c xmlsave.c
  xmlschemas.c xpath.c xpointer.c: mostly removing unneded affectations,
  but this led to a few real bugs and some part not yet understood
  (relaxng/interleave)
2009-09-07 14:58:47 +02:00