Remove includes of "config.h", <libxslt/xsltconfig.h> and
<libxml/xmlversion.h> in libexslt C sources since they are
already included with "libexslt/libexslt.h".
When encountering invalid UTF-8, xmlUTF8Size can return a size greater
than the actual string length or -1. Switch to xmlUTF8Strsize which
returns a sensible size even with invalid UTF-8.
Under normal conditions, libxslt should never receive invalid UTF-8.
But this change helps when fuzzing and hardens security.
Check whether xmlUTF8Strlen returns -1 for invalid UTF-8.
Under normal conditions, libxslt should never receive invalid UTF-8.
But this change helps when fuzzing and hardens security.
The psvi slot of RVTs documents is used to store ownership information.
XSLT_RVT_LOCAL for RVTs that are destroyed after the current instructions
ends.
XSLT_RVT_VARIABLE for RVTs that are part of a local variable and are
destroyed after the variable goes out of scope.
XSLT_RVT_FUNC_RESULT for RVTs that are part of results returned with
func:result. These RVTs won't be destroyed after exiting a template and
will be reset to XSLT_RVT_LOCAL or XSLT_RVT_VARIABLE in the template
that receives the return value.
XSLT_RVT_GLOBAL for RVTs that are part of a global variable.
The function xsltFlagRVTs is used for the following ownership
transitions:
- LOCAL or VARIABLE to FUNC_RESULT when returning a value with
func:result.
- FUNC_RESULT to LOCAL or VARIABLE when receiving a func:result.
- LOCAL to GLOBAL after evaluating global variables or parameters.
This obsoletes the element localRVTBase in the context struct and the
xsltExtensionInstructionResultRegister function. Aside from the
func:result implementation, the only reason for the old mechanism was
to protect RVTs (which can only be returned from extension functions)
in global variables from being destroyed too early. This is done
automatically now, so there's no need for extension authors to call
this function anymore.
The function xsltExtensionInstructionResultFinalize is unsupported
now. To the best of my knowledge, it isn't used outside of libxslt.
Another benefit is that, in some cases, RVTs are freed earlier now.
Also fixes bug #602531.
the str:replace() function is no longer usable without a transform
context. I take it from the bug report that it is not supposed to be used
from plain XPath but only from XSLT according to the EXSLT specification.
However, the previous implementation used to work in XPath and is still
registered on an xmlXPathContext by the exsltStrXpathCtxtRegister()
function. When called from plain XPath, it results in a memory error in
line 526 (exsltStrReturnString()) of strings.c because xsltCreateRVT()
returns NULL as an error indicator due to a NULL transform context being
passed in, which was the return value from xsltXPathGetTransformContext() a
bit further up (and the code doesn't validate that).
Since fixing the function looks impossible, best is to remove it.
For https://bugzilla.gnome.org/show_bug.cgi?id=569703
The libexslt implementation of str:replace fails to conform to its
specification on several counts:
a) the current version returns a string; it's supposed to
return a nodeset.
b) the current version treats the replacements as strings;
it's supposed to treat them as nodes.
c) the current version can modify replacement text; it's
supposed to only modify text from the original string.
d) the current version ignores the requirement to perform
substitutions in descending order of search string length.
Steps to reproduce:
a) the returning of a string rather than a nodeset can be seen
by simply inspecting the code.
b) the code explicity converts replacement nodes to strings;
this can be seen by inspection.
d) the failure to perform substitutions in descending order
of search string length can be seen in the lack of any
sorting in the source code.
c) the problem of modifying text not belonging to the original
string can be seen in the following stylesheet, which can
be simply applied to itself to produce output.
<xsl:stylesheet version="1.0"
extension-element-prefixes="str exsl"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:exsl="http://exslt.org/common"
xmlns:str="http://exslt.org/strings"
>
<xsl:variable name="Text">
Price is $1.10
</xsl:variable>
<xsl:template match="/">
<xsl:apply-templates select="exsl:node-set($Text)/text()"/>
</xsl:template>
<xsl:template match="text()">
<xsl:variable name="Replace">
<FromXml>
<from>$</from>
<from>\</from>
</FromXml>
<ToTex>
<to>\$</to>
<to>$\backslash$</to>
</ToTex>
</xsl:variable>
<xsl:value-of
select="str:replace(.,exsl:node-set($Replace)/FromXml/from,exsl:node-set($Replace)/ToTex/to)"/>
</xsl:template>
</xsl:stylesheet>
Actual results:
The output is:
<?xml version="1.0"?>
Price is $\backslash$$1.10
Expected results:
The output should be:
<?xml version="1.0"?>
Price is \$1.10
Does this happen every time?
yes.
Other information:
str:replace specification is at:
http://www.exslt.org/str/functions/replace/str.replace.html
* libexslt/strings.c: Added code to mark the results of
str:tokenize and str:split as "function result" to avoid
garbage-collecting them during global variable initialisation.
Should fix bug #495995.
svn path=/trunk/; revision=1448
* libexslt/strings.c: added new function replace from Joel
Reed.
* tests/exslt/Makefile.am, replace.1.xml, replace.1.xsl,
replace.1.out: added new test case for above.
* libxslt.spec.in: trivial change from Gnome to GNOME
* configure.in: trivial change for flags on my compilations
* libxslt/documents.c, libxslt/documents.h, libxslt/keys.c,
libxslt/keys.h, libxslt/variables.c, libxslt/templates.c,
libxslt/transform.c, libxslt/variables.c, libxslt/xslt.c,
libxslt/xsltutils.c: fixed some documentation/comments and
compilation warnings - no change to logic.
* re-generated the documentation.
svn path=/trunk/; revision=1413
* libxslt/attributes.c libxslt/documents.c
libxslt/functions.c libxslt/keys.c libxslt/namespaces.c
libxslt/pattern.c libxslt/preproc.c libxslt/templates.c
libxslt/templates.h libxslt/transform.c
libxslt/variables.c libxslt/xslt.c
libxslt/xsltInternals.h libxslt/xsltutils.c
libxslt/xsltutils.h libexslt/common.c libexslt/dynamic.c
libexslt/functions.c libexslt/strings.c:
Committing again, since I forgot to switch from win to linux
linebreaks in the files.
* libxslt/attributes.c libxslt/documents.c
libxslt/functions.c libxslt/keys.c libxslt/namespaces.c
libxslt/pattern.c libxslt/preproc.c libxslt/templates.c
libxslt/templates.h libxslt/transform.c libxslt/variables.c
libxslt/xslt.c libxslt/xsltInternals.h libxslt/xsltutils.c
libxslt/xsltutils.h libexslt/common.c libexslt/dynamic.c
libexslt/functions.c libexslt/strings.c:
Refactored xsltValueOf(). Changed to use xmlXPathCastToString()
directly, rather than creating an intermediate object with
xmlXPathConvertString(). This now does not add a text-node to
the result if the string is empty (this has impact on
serialization, since an empty text-node is serialized as
<foo></foo>, and now it will be serialized as <foo/>).
Refactored other functions in transform.c:
Mostly code cleanup/restructuring. Minimized number of
function variables for instruction which eat up function stack
memory when recursing templates (xsltIf(), xsltChoose(),
xsltApplyTemplates(), xsltCallTemplate()).
Changed XSLT tests to use xmlXPathCompiledEvalToBoolean().
Implemented redefinition checks at compilation-time and
eliminating them at transformation time in the refactored code
paths.
Introduced the field @currentTemplateRule on xsltTransformContext to
reflect the "Current Template Rule" as defined by the spec.
NOTE that ctxt->currentTemplateRule and ctxt->templ is not the
same; the former is the "Current Template Rule" as defined by the
XSLT spec, the latter is simply the template struct being
currently processed by Libxslt.
Added XML_COMMENT_NODE and XML_CDATA_SECTION_NODE to the macro
IS_XSLT_REAL_NODE.
Misc code cleanup/restructuring and everything else I already forgot.
Refactored lifetime of temporary result tree fragments.
Substituted all calls to the now deprecated xsltRegisterTmpRVT()
for the new xsltRegisterLocalRVT().
Fragments of xsl:variable and xsl:param are freed when the
variable/pram is freed.
Fragments created when evaluating a "select" of xsl:varible and
xsl:param are also bound to the lifetime of the var/param.
EXSLT's func:function now uses the following functions to let take
care the transformation's garbage collector of returned tree
fragments:
xsltExtensionInstructionResultRegister(),
xsltExtensionInstructionResultFinalize()
Fixes:
#339222 - xsl:param at invalid position inside an xsl:template is
not catched
#346015 - Non-declared caller-parameters are accepted
#160400 - Compiles invalid XSLT; unbound variable accepted
#308441 - namespaced parameters become unregistered
#307103 - problem with proximity position in predicates of match
patterns
#328218 - problem with exsl:node-set() when converting strings
to node sets
#318088 - infinite recursion detection
#321505 - Multiple contiguous CDATA in output
#334493 - "--param" option does not have root context
#114377 - weird func:result/xsl:variable/exsl:node-set interaction
#150309 - Regression caused by fix for 142768
* libexslt/strings.c: fixed str:tokenize for case when 2nd
argument is an empty string (should produce a token for
each char in the string). Reported on the mailing list by
Peter Pawlowski.
* libexslt/strings.c: fixed entity problem in exslt:tokenize
uncovered by newapi.xsl
* libxslt/transform.c,libxslt/pattern.c,libxslt/keys.c: changed
to use IS_BLANK_CH for char compares (fixes warnings)
* libexslt/strings.c: fix bug #125265 about entities breaking
exsl:tokenize and exsl:split
* tests/exslt/strings/split.1.* tests/exslt/strings/tokenize.1.*:
augmented the reression tests with the example from the bug report.
Daniel
* xsltproc/Makefile.am libxslt/libxslt.h libxslt/numbersInternals.h
libexslt/*.c configure.in: applied patch from Mikhail Grushinskiy
for compilation with MingW compiler on Windows.
Daniel
* libexslt/strings.c: applied patch from Shaun McCance to fix bug
#117616 about EXST str:tokenize.
* tests/exslt/strings/Makefile.am tests/exslt/strings/tokenize.3.*:
added the test in the regression suite.
Daniel
* libexslt/strings.c: applied patch from Shaun McCance to implement
exslt:split c.f. #117752
* tests/exslt/strings/Makefile.am tests/exslt/strings/split.1.*:
added the test to the regression suite.
Daniel
* libxslt/transform.c libxslt/variables.c libxslt/xsltInternals.h:
cleaning up Result Value Tree handling
* libexslt/functions.c libexslt/strings.c: fixed a pair of
implementations.
* tests/exslt/strings/Makefile.am tests/exslt/strings/tokenize.2.*:
added Mark Vakoc test combining for-each and exslt:tokenize
Daniel
* python/generator.py: fixed a problem in the generator where
the way functions are remapped as methods on classes was
not symetric and dependant on python internal hash order,
as reported by Stphane Bidoul
* libexslt/strings.c: attempt at fixing an object type pbm
* libxslt/triodef.h: update for OpenVMS from libxml2
Daniel
* libexslt/strings.c: applied last patch for #110023 from
Mark Vakoc
* libexslt/sets.c: fixed a memory leak when mixing one of the
EXSLT set functions and a Result Value Tree
* TODO: there are other bugs around in libexslt/sets.c in conjunction
with Result Value Tree
Daniel
* configure.in: preparing 1.0.14
* doc/*: updated rebuilt
* libxslt/*.c libexslt/*.c libxslt/libxslt.h libexslt/libexslt.h:
implemented the IN_LIBXSLT and IN_LIBEXSLT mechanism discussed
with the Windows maintainers
Daniel
* libexslt/saxon.c: fixed a typo and improved handling of
non-XPath-expression arguments.
* libexslt/strings.c: fixed a bug in tokenize: function was using
tctxt->output instead of tctxt->document->doc.
* libxslt/transform.c: fixed a bug in xsltDefaultProcessOneNode
which was using variable "node" instead of "cur"
* libxslt/extra.c : close#59570 by simply not providing
Norm's extension on FreeBSD.
* tests/general tests/docs: added a couple of new entries
in the testsuite
* libexslt/strings.c: NULL initialized a local variable
which was tested later on.
Daniel
* libexslt/Makefile.am libexslt/exslt.[ch] libexslt/strings.c:
added implementation of EXSLT - Strings.
Currently implemented functins are str:tokenize, str:align
str:concat and str:padding.
* configure.in tests/exslt/Makefile.am
tests/exslt/strings/Makefile.am
tests/exslt/strings/tokenize.1.*: added a test for the
str:tokenize function.