Commit ec39a33e authored by Nick Wellnhofer's avatar Nick Wellnhofer

Fix str:align with UTF-8 strings

The offset computation for left-aligned strings containing UTF-8 was
wrong. Fixes bug #588544:

Also add some test cases.
parent de1fca61
......@@ -447,7 +447,7 @@ exsltStrAlignFunction (xmlXPathParserContextPtr ctxt, int nargs) {
} else {
int str_s;
str_s = xmlStrlen (str);
str_s = xmlUTF8Strsize(padding, str_l);
ret = xmlStrdup (str);
ret = xmlStrcat (ret, padding + str_s);
<?xml version="1.0"?>
<test-result>déja vu––––––</test-result>
<test-result>–––déja vu–––</test-result>
<test-result>––––––déja vu</test-result>
<test-result>déja vu</test-result>
<?xml version="1.0"?>
<test-case string="déja vu" padding="–––––––––––––" alignment="left"/>
<test-case string="déja vu" padding="–––––––––––––" alignment="center"/>
<test-case string="déja vu" padding="–––––––––––––" alignment="right"/>
<test-case string="déja vu" padding="––––" alignment="left"/>
<test-case string="déja vu" padding="–––––––" alignment="left"/>
<?xml version="1.0"?>
<xsl:stylesheet version="1.0"
<xsl:output indent="yes"/>
<xsl:template match="test-cases">
<xsl:apply-templates select="test-case"/>
<xsl:template match="test-case">
<xsl:value-of select="str:align(@string, @padding, @alignment)"/>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment