From 43d097418cd355effae9a2045583d833276de508 Mon Sep 17 00:00:00 2001 From: Eugene Dorfman Date: Sun, 30 Aug 2015 22:54:57 +0200 Subject: [PATCH 1/2] regexp.c: minor fixes for UTF8 strings matching --- regexp.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/regexp.c b/regexp.c index e1858d8..c52907c 100644 --- a/regexp.c +++ b/regexp.c @@ -9,6 +9,7 @@ * Authors: * Joel W. Reed * Some modification by Kyle Maxwell + * Minor fix for UTF8 strings by Eugene Dorfman * * TODO: * functions: @@ -66,7 +67,7 @@ exsltRegexpExecute(xmlXPathParserContextPtr ctxt, haystack, /* the subject string */ haystack_len, /* the length of the subject string */ 0, /* start at offset 0 in the subject */ - 0, /* default options */ + PCRE_NO_UTF8_CHECK, /* default options */ (int*)ovector, /* vector of integers for substring information */ ovector_len); /* number of elements in the vector (NOT size in bytes) */ @@ -149,8 +150,8 @@ exsltRegexpMatchFunction (xmlXPathParserContextPtr ctxt, int nargs) while (rc > 0) { for(int group = 0; group < rc; group++) { - match = xmlStrsub(working, ovector[group*2], ovector[group*2+1]-ovector[group*2]); - if (NULL == match) goto fail; + match = xmlUTF8Strsub(working, ovector[group*2], ovector[group*2+1]-ovector[group*2]); + if (NULL == match || 0 == xmlUTF8Strlen(match)) goto fail; node = xmlNewDocRawNode(container, NULL, "match", match); xmlFree(match); @@ -160,7 +161,7 @@ exsltRegexpMatchFunction (xmlXPathParserContextPtr ctxt, int nargs) } if (!global) break; - working = working + ovector[1]; + working = xmlUTF8Strpos(working,ovector[1]); rc = exsltRegexpExecute(ctxt, working, regexp, flags, ovector, sizeof(ovector)/sizeof(int)); } From cd2daecee69063d2230f67ee864c62f053b93084 Mon Sep 17 00:00:00 2001 From: Eugene Dorfman Date: Mon, 31 Aug 2015 00:13:18 +0200 Subject: [PATCH 2/2] added pcre error code to error reporting --- regexp.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/regexp.c b/regexp.c index c52907c..c5d4d88 100644 --- a/regexp.c +++ b/regexp.c @@ -73,7 +73,7 @@ exsltRegexpExecute(xmlXPathParserContextPtr ctxt, if (rc < -1) { xsltTransformError (xsltXPathGetTransformContext (ctxt), NULL, NULL, - "exslt:regexp failed to execute %s for %s", regexp, haystack); + "exslt:regexp failed to execute %s for %s with error code: %d ", regexp, haystack, rc); rc = 0; }