php-internal-docs 8.4.8
Unofficial docs for php/php-src
Loading...
Searching...
No Matches
xsltprocessor.c
Go to the documentation of this file.
1/*
2 +----------------------------------------------------------------------+
3 | Copyright (c) The PHP Group |
4 +----------------------------------------------------------------------+
5 | This source file is subject to version 3.01 of the PHP license, |
6 | that is bundled with this package in the file LICENSE, and is |
7 | available through the world-wide-web at the following url: |
8 | https://www.php.net/license/3_01.txt |
9 | If you did not receive a copy of the PHP license and are unable to |
10 | obtain it through the world-wide-web, please send a note to |
11 | license@php.net so we can mail you a copy immediately. |
12 +----------------------------------------------------------------------+
13 | Authors: Christian Stocker <chregu@php.net> |
14 | Rob Richards <rrichards@php.net> |
15 +----------------------------------------------------------------------+
16*/
17
18#ifdef HAVE_CONFIG_H
19#include <config.h>
20#endif
21
22#include "php.h"
23#include "php_xsl.h"
24#include <libxslt/variables.h>
27
28
29static zend_result php_xsl_xslt_apply_params(xsltTransformContextPtr ctxt, HashTable *params)
30{
31 zend_string *string_key;
32 zval *value;
33
34 ZEND_HASH_MAP_FOREACH_STR_KEY_VAL(params, string_key, value) {
35 ZEND_ASSERT(string_key != NULL);
36 /* Already a string because of setParameter() */
38
39 int result = xsltQuoteOneUserParam(ctxt, (const xmlChar *) ZSTR_VAL(string_key), (const xmlChar *) Z_STRVAL_P(value));
40 if (result < 0) {
41 php_error_docref(NULL, E_WARNING, "Could not apply parameter \"%s\"", ZSTR_VAL(string_key));
42 return FAILURE;
43 }
45
46 return SUCCESS;
47}
48
49static void xsl_proxy_factory(xmlNodePtr node, zval *child, dom_object *intern, xmlXPathParserContextPtr ctxt)
50{
51 ZEND_ASSERT(node->type != XML_NAMESPACE_DECL);
52
62 xsltTransformContextPtr transform_ctxt = (xsltTransformContextPtr) ctxt->context->extra;
63 if (node->doc != transform_ctxt->document->doc) {
64 node = xmlDocCopyNode(node, intern->document->ptr, 1);
65 }
66 php_dom_create_object(node, child, intern);
67}
68
69static xsl_object *xsl_ext_fetch_intern(xmlXPathParserContextPtr ctxt)
70{
72 xsltGenericError(xsltGenericErrorContext,
73 "xsltExtFunctionTest: Function called from outside of PHP\n");
74 return NULL;
75 }
76
77 xsltTransformContextPtr tctxt = xsltXPathGetTransformContext(ctxt);
78 if (UNEXPECTED(tctxt == NULL)) {
79 xsltGenericError(xsltGenericErrorContext,
80 "xsltExtFunctionTest: failed to get the transformation context\n");
81 return NULL;
82 }
83
84 xsl_object *intern = (xsl_object *) tctxt->_private;
85 if (UNEXPECTED(intern == NULL)) {
86 xsltGenericError(xsltGenericErrorContext,
87 "xsltExtFunctionTest: failed to get the internal object\n");
88 return NULL;
89 }
90 return intern;
91}
92
93static void xsl_ext_function_php(xmlXPathParserContextPtr ctxt, int nargs, php_dom_xpath_nodeset_evaluation_mode evaluation_mode) /* {{{ */
94{
95 xsl_object *intern = xsl_ext_fetch_intern(ctxt);
96 if (!intern) {
98 } else {
99 php_dom_xpath_callbacks_call_php_ns(&intern->xpath_callbacks, ctxt, nargs, evaluation_mode, (dom_object *) intern->doc, xsl_proxy_factory);
100 }
101}
102/* }}} */
103
104void xsl_ext_function_string_php(xmlXPathParserContextPtr ctxt, int nargs) /* {{{ */
105{
106 xsl_ext_function_php(ctxt, nargs, PHP_DOM_XPATH_EVALUATE_NODESET_TO_STRING);
107}
108/* }}} */
109
110void xsl_ext_function_object_php(xmlXPathParserContextPtr ctxt, int nargs) /* {{{ */
111{
112 xsl_ext_function_php(ctxt, nargs, PHP_DOM_XPATH_EVALUATE_NODESET_TO_NODESET);
113}
114/* }}} */
115
116static void xsl_ext_function_trampoline(xmlXPathParserContextPtr ctxt, int nargs)
117{
118 xsl_object *intern = xsl_ext_fetch_intern(ctxt);
119 if (!intern) {
121 } else {
123 }
124}
125
126static void xsl_add_ns_to_map(xmlHashTablePtr table, xsltStylesheetPtr sheet, const xmlNode *cur, const xmlChar *prefix, const xmlChar *uri)
127{
128 const xmlChar *existing_url = xmlHashLookup(table, prefix);
129 if (existing_url != NULL && !xmlStrEqual(existing_url, uri)) {
130 xsltTransformError(NULL, sheet, (xmlNodePtr) cur, "Namespaces prefix %s used for multiple namespaces\n", prefix);
131 sheet->warnings++;
132 } else if (existing_url == NULL) {
133 xmlHashUpdateEntry(table, prefix, (void *) uri, NULL);
134 }
135}
136
137/* Adds all namespace declaration (not using nsDef) into a hash map that maps prefix to uri. Warns on conflicting declarations. */
138static void xsl_build_ns_map(xmlHashTablePtr table, xsltStylesheetPtr sheet, php_dom_libxml_ns_mapper *ns_mapper, const xmlDoc *doc)
139{
140 const xmlNode *cur = xmlDocGetRootElement(doc);
141
142 while (cur != NULL) {
143 if (cur->type == XML_ELEMENT_NODE) {
144 if (cur->ns != NULL && cur->ns->prefix != NULL) {
145 xsl_add_ns_to_map(table, sheet, cur, cur->ns->prefix, cur->ns->href);
146 }
147
148 for (const xmlAttr *attr = cur->properties; attr != NULL; attr = attr->next) {
149 if (attr->ns != NULL && attr->ns->prefix != NULL && php_dom_ns_is_fast_ex(attr->ns, php_dom_ns_is_xmlns_magic_token)
150 && attr->children != NULL && attr->children->content != NULL) {
151 /* This attribute declares a namespace, get the relevant instance.
152 * The declared namespace is not the same as the namespace of this attribute (which is xmlns). */
153 const xmlChar *prefix = attr->name;
154 xmlNsPtr ns = php_dom_libxml_ns_mapper_get_ns_raw_strings_nullsafe(ns_mapper, (const char *) prefix, (const char *) attr->children->content);
155 xsl_add_ns_to_map(table, sheet, cur, prefix, ns->href);
156 }
157 }
158 }
159
160 cur = php_dom_next_in_tree_order(cur, (const xmlNode *) doc);
161 }
162}
163
164/* Apply namespace corrections for new DOM */
170
171static zend_always_inline xsl_ns_hash_correction_status xsl_apply_ns_hash_corrections(xsltStylesheetPtr sheetp, xmlNodePtr nodep, xmlDocPtr doc)
172{
173 if (sheetp->nsHash == NULL) {
174 dom_object *node_intern = php_dom_object_get_data(nodep);
175 if (node_intern != NULL && php_dom_follow_spec_intern(node_intern)) {
176 sheetp->nsHash = xmlHashCreate(10);
177 if (UNEXPECTED(!sheetp->nsHash)) {
179 }
180 xsl_build_ns_map(sheetp->nsHash, sheetp, php_dom_get_ns_mapper(node_intern), doc);
182 }
183 }
185}
186
187/* {{{ URL: http://www.w3.org/TR/2003/WD-DOM-Level-3-Core-20030226/DOM3-Core.html#
188Since:
189*/
190PHP_METHOD(XSLTProcessor, importStylesheet)
191{
192 zval *id, *docp = NULL;
193 xmlDoc *doc = NULL, *newdoc = NULL;
194 xsltStylesheetPtr sheetp;
195 bool clone_docu = false;
196 xmlNode *nodep = NULL;
197 zval *cloneDocu, rv;
198 zend_string *member;
199
200 id = ZEND_THIS;
201 if (zend_parse_parameters(ZEND_NUM_ARGS(), "o", &docp) == FAILURE) {
203 }
204
205 nodep = php_libxml_import_node(docp);
206
207 if (nodep) {
208 doc = nodep->doc;
209 }
210 if (doc == NULL) {
211 zend_argument_type_error(1, "must be a valid XML node");
213 }
214
215 /* libxslt uses _private, so we must copy the imported
216 stylesheet document otherwise the node proxies will be a mess */
217 newdoc = xmlCopyDoc(doc, 1);
218 xmlNodeSetBase((xmlNodePtr) newdoc, (xmlChar *)doc->URL);
219 PHP_LIBXML_SANITIZE_GLOBALS(parse);
220 ZEND_DIAGNOSTIC_IGNORED_START("-Wdeprecated-declarations")
221 xmlSubstituteEntitiesDefault(1);
222 xmlLoadExtDtdDefaultValue = XML_DETECT_IDS | XML_COMPLETE_ATTRS;
224
225 sheetp = xsltParseStylesheetDoc(newdoc);
226 PHP_LIBXML_RESTORE_GLOBALS(parse);
227
228 if (!sheetp) {
229 xmlFreeDoc(newdoc);
231 }
232
233 xsl_object *intern = Z_XSL_P(id);
234
235 xsl_ns_hash_correction_status status = xsl_apply_ns_hash_corrections(sheetp, nodep, doc);
237 xsltFreeStylesheet(sheetp);
238 xmlFreeDoc(newdoc);
241 /* The namespace mappings need to be kept alive.
242 * This is stored in the ref obj outside of libxml2, but that means that the sheet won't keep it alive
243 * unlike with namespaces from old DOM. */
244 if (intern->sheet_ref_obj) {
245 php_libxml_decrement_doc_ref_directly(intern->sheet_ref_obj);
246 }
247 intern->sheet_ref_obj = Z_LIBXML_NODE_P(docp)->document;
248 intern->sheet_ref_obj->refcount++;
249 }
250
251 member = ZSTR_INIT_LITERAL("cloneDocument", 0);
252 cloneDocu = zend_std_read_property(Z_OBJ_P(id), member, BP_VAR_R, NULL, &rv);
253 clone_docu = zend_is_true(cloneDocu);
254 zend_string_release_ex(member, 0);
255 if (!clone_docu) {
256 /* Check if the stylesheet is using xsl:key, if yes, we have to clone the document _always_ before a transformation.
257 * xsl:key elements may only occur at the top level. Furthermore, all elements at the top level must be in a
258 * namespace (if not, then the stylesheet is not well-formed and this function will have returned false earlier). */
259 nodep = xmlDocGetRootElement(sheetp->doc);
260 if (nodep && (nodep = nodep->children)) {
261 while (nodep) {
262 ZEND_ASSERT(nodep->ns != NULL);
263 if (nodep->type == XML_ELEMENT_NODE && xmlStrEqual(nodep->name, (const xmlChar *) "key") && xmlStrEqual(nodep->ns->href, XSLT_NAMESPACE)) {
264 intern->hasKeys = true;
265 break;
266 }
267 nodep = nodep->next;
268 }
269 }
270 } else {
271 intern->hasKeys = true;
272 }
273
274 xsl_free_sheet(intern);
275
276 php_xsl_set_object(id, sheetp);
278}
279/* }}} end XSLTProcessor::importStylesheet */
280
281static void php_xsl_delayed_lib_registration(void *ctxt, const zend_string *ns, const zend_string *name)
282{
283 xsltTransformContextPtr xsl = (xsltTransformContextPtr) ctxt;
284 xsltRegisterExtFunction(xsl, (const xmlChar *) ZSTR_VAL(name), (const xmlChar *) ZSTR_VAL(ns), xsl_ext_function_trampoline);
285}
286
287static xmlDocPtr php_xsl_apply_stylesheet(zval *id, xsl_object *intern, xsltStylesheetPtr style, zval *docp) /* {{{ */
288{
289 xmlDocPtr newdocp = NULL;
290 xmlDocPtr doc = NULL;
291 xmlNodePtr node = NULL;
292 xsltTransformContextPtr ctxt;
293 php_libxml_node_object *object;
294 zval *doXInclude, rv;
295 zend_string *member;
296 FILE *f;
297 int secPrefsError = 0;
298 xsltSecurityPrefsPtr secPrefs = NULL;
299
300 node = php_libxml_import_node(docp);
301
302 if (node) {
303 doc = node->doc;
304 }
305
306 if (doc == NULL) {
307 zend_argument_type_error(1, "must be a valid XML node");
308 return NULL;
309 }
310
311 if (style == NULL) {
313 zend_throw_error(NULL, "%s() can only be called after a stylesheet has been imported",
314 ZSTR_VAL(name));
315 zend_string_release(name);
316 return NULL;
317 }
318
319 if (intern->profiling) {
321 f = NULL;
322 } else {
323 f = VCWD_FOPEN(ZSTR_VAL(intern->profiling), "w");
324 }
325 } else {
326 f = NULL;
327 }
328
329 intern->doc = emalloc(sizeof(php_libxml_node_object));
330 memset(intern->doc, 0, sizeof(php_libxml_node_object));
331
332 if (intern->hasKeys) {
333 doc = xmlCopyDoc(doc, 1);
334 } else {
335 object = Z_LIBXML_NODE_P(docp);
336 intern->doc->document = object->document;
337 }
338
339 php_libxml_increment_doc_ref(intern->doc, doc);
340
341 ctxt = xsltNewTransformContext(style, doc);
342 ctxt->_private = (void *) intern;
343
344 if (intern->parameter) {
345 zend_result status = php_xsl_xslt_apply_params(ctxt, intern->parameter);
346 if (UNEXPECTED(status != SUCCESS) && EG(exception)) {
347 goto out;
348 }
349 }
350
351 member = ZSTR_INIT_LITERAL("doXInclude", 0);
352 doXInclude = zend_std_read_property(Z_OBJ_P(id), member, BP_VAR_R, NULL, &rv);
353 ctxt->xinclude = zend_is_true(doXInclude);
354 zend_string_release_ex(member, 0);
355
356 zval *max_template_depth = xsl_prop_max_template_depth(Z_OBJ_P(id));
357 ZEND_ASSERT(Z_TYPE_P(max_template_depth) == IS_LONG);
358 ctxt->maxTemplateDepth = Z_LVAL_P(max_template_depth);
359
360 zval *max_template_vars = xsl_prop_max_template_vars(Z_OBJ_P(id));
361 ZEND_ASSERT(Z_TYPE_P(max_template_vars) == IS_LONG);
362 ctxt->maxTemplateVars = Z_LVAL_P(max_template_vars);
363
364 zend_long secPrefsValue = intern->securityPrefs;
365
366 /* if securityPrefs is set to NONE, we don't have to do any checks, but otherwise... */
367 if (secPrefsValue != XSL_SECPREF_NONE) {
368 secPrefs = xsltNewSecurityPrefs();
369 if (secPrefsValue & XSL_SECPREF_READ_FILE ) {
370 if (0 != xsltSetSecurityPrefs(secPrefs, XSLT_SECPREF_READ_FILE, xsltSecurityForbid)) {
371 secPrefsError = 1;
372 }
373 }
374 if (secPrefsValue & XSL_SECPREF_WRITE_FILE ) {
375 if (0 != xsltSetSecurityPrefs(secPrefs, XSLT_SECPREF_WRITE_FILE, xsltSecurityForbid)) {
376 secPrefsError = 1;
377 }
378 }
379 if (secPrefsValue & XSL_SECPREF_CREATE_DIRECTORY ) {
380 if (0 != xsltSetSecurityPrefs(secPrefs, XSLT_SECPREF_CREATE_DIRECTORY, xsltSecurityForbid)) {
381 secPrefsError = 1;
382 }
383 }
384 if (secPrefsValue & XSL_SECPREF_READ_NETWORK) {
385 if (0 != xsltSetSecurityPrefs(secPrefs, XSLT_SECPREF_READ_NETWORK, xsltSecurityForbid)) {
386 secPrefsError = 1;
387 }
388 }
389 if (secPrefsValue & XSL_SECPREF_WRITE_NETWORK) {
390 if (0 != xsltSetSecurityPrefs(secPrefs, XSLT_SECPREF_WRITE_NETWORK, xsltSecurityForbid)) {
391 secPrefsError = 1;
392 }
393 }
394
395 if (0 != xsltSetCtxtSecurityPrefs(secPrefs, ctxt)) {
396 secPrefsError = 1;
397 }
398 }
399
400 php_dom_xpath_callbacks_delayed_lib_registration(&intern->xpath_callbacks, ctxt, php_xsl_delayed_lib_registration);
401
402 if (secPrefsError == 1) {
403 php_error_docref(NULL, E_WARNING, "Can't set libxslt security properties, not doing transformation for security reasons");
404 } else {
405 newdocp = xsltApplyStylesheetUser(style, doc, /* params (handled manually) */ NULL, /* output */ NULL, f, ctxt);
406 }
407
408out:
409 if (f) {
410 fclose(f);
411 }
412
413 xsltFreeTransformContext(ctxt);
414 if (secPrefs) {
415 xsltFreeSecurityPrefs(secPrefs);
416 }
417
419
420 php_libxml_decrement_doc_ref(intern->doc);
421 efree(intern->doc);
422 intern->doc = NULL;
423
424 return newdocp;
425
426}
427/* }}} */
428
429/* {{{ URL: http://www.w3.org/TR/2003/WD-DOM-Level-3-Core-20030226/DOM3-Core.html#
430Since:
431*/
432PHP_METHOD(XSLTProcessor, transformToDoc)
433{
434 zval *id, *docp = NULL;
435 xmlDoc *newdocp;
436 xsltStylesheetPtr sheetp;
437 zend_class_entry *ret_class = NULL;
438 xsl_object *intern;
439
440 id = ZEND_THIS;
441 intern = Z_XSL_P(id);
442 sheetp = (xsltStylesheetPtr) intern->ptr;
443
444 if (zend_parse_parameters(ZEND_NUM_ARGS(), "o|C!", &docp, &ret_class) == FAILURE) {
446 }
447
448 newdocp = php_xsl_apply_stylesheet(id, intern, sheetp, docp);
449
450 if (newdocp) {
451 if (ret_class) {
452 zend_string *curclass_name;
453 zend_class_entry *curce;
454 php_libxml_node_object *interndoc;
455
456 curce = Z_OBJCE_P(docp);
457 curclass_name = curce->name;
458 while (curce->parent != NULL) {
459 curce = curce->parent;
460 }
461
462 if (!instanceof_function(ret_class, curce)) {
463 xmlFreeDoc(newdocp);
464 zend_argument_type_error(2, "must be a class name compatible with %s, %s given",
465 ZSTR_VAL(curclass_name), ZSTR_VAL(ret_class->name)
466 );
468 }
469
470 object_init_ex(return_value, ret_class);
471
472 interndoc = Z_LIBXML_NODE_P(return_value);
473 php_libxml_increment_doc_ref(interndoc, newdocp);
474 php_libxml_increment_node_ptr(interndoc, (xmlNodePtr)newdocp, (void *)interndoc);
475 } else {
476 php_dom_create_object((xmlNodePtr) newdocp, return_value, NULL);
477 }
478 } else {
480 }
481}
482/* }}} end XSLTProcessor::transformToDoc */
483
484/* {{{ */
485PHP_METHOD(XSLTProcessor, transformToUri)
486{
487 zval *id, *docp = NULL;
488 xmlDoc *newdocp;
489 xsltStylesheetPtr sheetp;
490 int ret;
491 size_t uri_len;
492 char *uri;
493 xsl_object *intern;
494
495 id = ZEND_THIS;
496 intern = Z_XSL_P(id);
497 sheetp = (xsltStylesheetPtr) intern->ptr;
498
499 if (zend_parse_parameters(ZEND_NUM_ARGS(), "op", &docp, &uri, &uri_len) == FAILURE) {
501 }
502
503 newdocp = php_xsl_apply_stylesheet(id, intern, sheetp, docp);
504
505 ret = -1;
506 if (newdocp) {
507 ret = xsltSaveResultToFilename(uri, newdocp, sheetp, 0);
508 xmlFreeDoc(newdocp);
509 }
510
512}
513/* }}} end XSLTProcessor::transformToUri */
514
515/* {{{ */
516PHP_METHOD(XSLTProcessor, transformToXml)
517{
518 zval *id, *docp = NULL;
519 xmlDoc *newdocp;
520 xsltStylesheetPtr sheetp;
521 int ret;
522 xmlChar *doc_txt_ptr;
523 int doc_txt_len;
524 xsl_object *intern;
525
526 id = ZEND_THIS;
527 intern = Z_XSL_P(id);
528 sheetp = (xsltStylesheetPtr) intern->ptr;
529
530 if (zend_parse_parameters(ZEND_NUM_ARGS(), "o", &docp) == FAILURE) {
532 }
533
534 newdocp = php_xsl_apply_stylesheet(id, intern, sheetp, docp);
535
536 ret = -1;
537 if (newdocp) {
538 ret = xsltSaveResultToString(&doc_txt_ptr, &doc_txt_len, newdocp, sheetp);
539 if (doc_txt_ptr && doc_txt_len) {
540 RETVAL_STRINGL((char *) doc_txt_ptr, doc_txt_len);
541 xmlFree(doc_txt_ptr);
542 }
543 xmlFreeDoc(newdocp);
544 }
545
546 if (ret < 0) {
548 }
549}
550/* }}} end XSLTProcessor::transformToXml */
551
552/* {{{ */
554{
555
556 zval *id = ZEND_THIS;
557 zval *entry, new_string;
558 HashTable *array_value;
559 xsl_object *intern;
560 char *namespace;
561 size_t namespace_len;
562 zend_string *string_key, *name, *value = NULL;
563
565 Z_PARAM_STRING(namespace, namespace_len)
566 Z_PARAM_ARRAY_HT_OR_STR(array_value, name)
570
571 intern = Z_XSL_P(id);
572
573 if (array_value) {
574 if (value) {
575 zend_argument_value_error(3, "must be null when argument #2 ($name) is an array");
577 }
578
579 ZEND_HASH_FOREACH_STR_KEY_VAL(array_value, string_key, entry) {
580 zval tmp;
581 zend_string *str;
582
583 if (string_key == NULL) {
584 zend_argument_type_error(2, "must contain only string keys");
586 }
587
588 if (UNEXPECTED(CHECK_NULL_PATH(ZSTR_VAL(string_key), ZSTR_LEN(string_key)))) {
589 zend_argument_value_error(3, "must not contain keys with any null bytes");
591 }
592
593 str = zval_try_get_string(entry);
594 if (UNEXPECTED(!str)) {
596 }
597
598 if (UNEXPECTED(CHECK_NULL_PATH(ZSTR_VAL(str), ZSTR_LEN(str)))) {
599 zend_string_release(str);
600 zend_argument_value_error(3, "must not contain values with any null bytes");
602 }
603
604 ZVAL_STR(&tmp, str);
605 zend_hash_update(intern->parameter, string_key, &tmp);
608 } else {
609 if (!value) {
610 zend_argument_value_error(3, "cannot be null when argument #2 ($name) is a string");
612 }
613
615 zend_argument_value_error(2, "must not contain any null bytes");
617 }
618
619 ZVAL_STR_COPY(&new_string, value);
620
621 zend_hash_update(intern->parameter, name, &new_string);
623 }
624}
625/* }}} end XSLTProcessor::setParameter */
626
627/* {{{ */
629{
630 zval *id = ZEND_THIS;
631 char *namespace;
632 size_t namespace_len = 0;
633 zval *value;
635 xsl_object *intern;
636
637 if (zend_parse_parameters(ZEND_NUM_ARGS(), "sS", &namespace, &namespace_len, &name) == FAILURE) {
639 }
640 intern = Z_XSL_P(id);
641 if ((value = zend_hash_find(intern->parameter, name)) != NULL) {
643 } else {
645 }
646}
647/* }}} end XSLTProcessor::getParameter */
648
649/* {{{ */
650PHP_METHOD(XSLTProcessor, removeParameter)
651{
652 zval *id = ZEND_THIS;
653 size_t namespace_len = 0;
654 char *namespace;
656 xsl_object *intern;
657
658 if (zend_parse_parameters(ZEND_NUM_ARGS(), "sS", &namespace, &namespace_len, &name) == FAILURE) {
660 }
661 intern = Z_XSL_P(id);
662 if (zend_hash_del(intern->parameter, name) == SUCCESS) {
664 } else {
666 }
667}
668/* }}} end XSLTProcessor::removeParameter */
669
670/* {{{ */
671PHP_METHOD(XSLTProcessor, registerPHPFunctions)
672{
673 xsl_object *intern = Z_XSL_P(ZEND_THIS);
674
676 HashTable *callable_ht = NULL;
677
682
684 &intern->xpath_callbacks,
685 NULL,
686 NULL,
687 name,
688 callable_ht,
690 NULL
691 );
692}
693/* }}} end XSLTProcessor::registerPHPFunctions(); */
694
695PHP_METHOD(XSLTProcessor, registerPHPFunctionNS)
696{
697 xsl_object *intern = Z_XSL_P(ZEND_THIS);
698
699 zend_string *namespace, *name;
700 zend_fcall_info fci;
702
704 Z_PARAM_PATH_STR(namespace)
708
709 if (zend_string_equals_literal(namespace, "http://php.net/xsl")) {
711 zend_argument_value_error(1, "must not be \"http://php.net/xsl\" because it is reserved by PHP");
713 }
714
716 &intern->xpath_callbacks,
717 NULL,
718 namespace,
719 name,
720 &fcc,
722 NULL
723 ) != SUCCESS) {
725 }
726}
727
728/* {{{ */
730{
731 zval *id = ZEND_THIS;
732 xsl_object *intern;
733 zend_string *filename = NULL;
734
735 if (zend_parse_parameters(ZEND_NUM_ARGS(), "P!", &filename) == FAILURE) {
737 }
738
739 intern = Z_XSL_P(id);
740 if (intern->profiling) {
741 zend_string_release(intern->profiling);
742 }
743 if (filename != NULL) {
744 intern->profiling = zend_string_copy(filename);
745 } else {
746 intern->profiling = NULL;
747 }
748
750}
751/* }}} end XSLTProcessor::setProfiling */
752
753/* {{{ */
754PHP_METHOD(XSLTProcessor, setSecurityPrefs)
755{
756 zval *id = ZEND_THIS;
757 xsl_object *intern;
758 zend_long securityPrefs, oldSecurityPrefs;
759
760 if (zend_parse_parameters(ZEND_NUM_ARGS(), "l", &securityPrefs) == FAILURE) {
762 }
763 intern = Z_XSL_P(id);
764 oldSecurityPrefs = intern->securityPrefs;
765 intern->securityPrefs = securityPrefs;
766 RETURN_LONG(oldSecurityPrefs);
767}
768/* }}} end XSLTProcessor::setSecurityPrefs */
769
770/* {{{ */
771PHP_METHOD(XSLTProcessor, getSecurityPrefs)
772{
773 zval *id = ZEND_THIS;
774 xsl_object *intern;
775
778 }
779
780 intern = Z_XSL_P(id);
781
782 RETURN_LONG(intern->securityPrefs);
783}
784/* }}} end XSLTProcessor::getSecurityPrefs */
785
786/* {{{ */
787PHP_METHOD(XSLTProcessor, hasExsltSupport)
788{
791 }
792
793#ifdef HAVE_XSL_EXSLT
795#else
797#endif
798}
799/* }}} end XSLTProcessor::hasExsltSupport(); */
bool exception
Definition assert.c:30
fclose($stream)
DNS_STATUS status
Definition dns_win32.c:49
memset(ptr, 0, type->size)
new_type attr
Definition ffi.c:4364
PHPAPI int php_check_open_basedir(const char *path)
#define NULL
Definition gdcache.h:45
#define prefix
#define SUCCESS
Definition hash_sha3.c:261
PHPAPI ZEND_COLD void php_error_docref(const char *docref, int type, const char *format,...)
Definition main.c:1173
PHP_DOM_EXPORT const php_dom_ns_magic_token * php_dom_ns_is_xmlns_magic_token
PHP_DOM_EXPORT bool php_dom_ns_is_fast_ex(xmlNsPtr ns, const php_dom_ns_magic_token *magic_token)
PHP_DOM_EXPORT php_dom_libxml_ns_mapper * php_dom_get_ns_mapper(dom_object *object)
PHP_DOM_EXPORT xmlNsPtr php_dom_libxml_ns_mapper_get_ns_raw_strings_nullsafe(php_dom_libxml_ns_mapper *mapper, const char *prefix, const char *uri)
#define PHP_METHOD
Definition php.h:365
const XML_ELEMENT_NODE
void xsl_free_sheet(xsl_object *intern)
Definition php_xsl.c:61
void php_xsl_set_object(zval *wrapper, void *obj)
Definition php_xsl.c:308
#define XSL_SECPREF_NONE
Definition php_xsl.h:46
#define XSL_SECPREF_WRITE_FILE
Definition php_xsl.h:48
#define Z_XSL_P(zv)
Definition php_xsl.h:71
#define XSL_SECPREF_CREATE_DIRECTORY
Definition php_xsl.h:49
zval * xsl_prop_max_template_vars(zend_object *object)
#define XSL_SECPREF_READ_NETWORK
Definition php_xsl.h:50
#define XSL_SECPREF_READ_FILE
Definition php_xsl.h:47
zval * xsl_prop_max_template_depth(zend_object *object)
#define XSL_SECPREF_WRITE_NETWORK
Definition php_xsl.h:51
zval rv
Definition session.c:1024
zend_string * name
Definition zend.h:149
zend_class_entry * parent
Definition zend.h:152
HashTable * parameter
Definition php_xsl.h:57
php_libxml_node_object * doc
Definition php_xsl.h:62
zend_string * profiling
Definition php_xsl.h:63
php_libxml_ref_obj * sheet_ref_obj
Definition php_xsl.h:59
php_dom_xpath_callbacks xpath_callbacks
Definition php_xsl.h:61
void * ptr
Definition php_xsl.h:56
zend_long securityPrefs
Definition php_xsl.h:60
bool hasKeys
Definition php_xsl.h:58
struct _dom_object dom_object
PHP_DOM_EXPORT dom_object * php_dom_object_get_data(xmlNodePtr obj)
PHP_DOM_EXPORT bool php_dom_create_object(xmlNodePtr obj, zval *return_value, dom_object *domobj)
PHP_DOM_EXPORT void php_dom_xpath_callbacks_clean_argument_stack(xmlXPathParserContextPtr ctxt, uint32_t num_args)
PHP_DOM_EXPORT zend_result php_dom_xpath_callbacks_update_method_handler(php_dom_xpath_callbacks *registry, xmlXPathContextPtr ctxt, zend_string *ns, zend_string *name, const HashTable *callable_ht, php_dom_xpath_callback_name_validation name_validation, php_dom_xpath_callbacks_register_func_ctx register_func)
PHP_DOM_EXPORT zend_result php_dom_xpath_callbacks_call_custom_ns(php_dom_xpath_callbacks *xpath_callbacks, xmlXPathParserContextPtr ctxt, int num_args, php_dom_xpath_nodeset_evaluation_mode evaluation_mode, dom_object *intern, php_dom_xpath_callbacks_proxy_factory proxy_factory)
PHP_DOM_EXPORT zend_result php_dom_xpath_callbacks_call_php_ns(php_dom_xpath_callbacks *xpath_callbacks, xmlXPathParserContextPtr ctxt, int num_args, php_dom_xpath_nodeset_evaluation_mode evaluation_mode, dom_object *intern, php_dom_xpath_callbacks_proxy_factory proxy_factory)
PHP_DOM_EXPORT void php_dom_xpath_callbacks_clean_node_list(php_dom_xpath_callbacks *registry)
@ PHP_DOM_XPATH_CALLBACK_NAME_VALIDATE_NCNAME
@ PHP_DOM_XPATH_CALLBACK_NAME_VALIDATE_NULLS
php_dom_xpath_nodeset_evaluation_mode
@ PHP_DOM_XPATH_EVALUATE_NODESET_TO_STRING
@ PHP_DOM_XPATH_EVALUATE_NODESET_TO_NODESET
PHP_DOM_EXPORT zend_result php_dom_xpath_callbacks_update_single_method_handler(php_dom_xpath_callbacks *registry, xmlXPathContextPtr ctxt, zend_string *ns, zend_string *name, const zend_fcall_info_cache *fcc, php_dom_xpath_callback_name_validation name_validation, php_dom_xpath_callbacks_register_func_ctx register_func)
PHP_DOM_EXPORT void php_dom_xpath_callbacks_delayed_lib_registration(const php_dom_xpath_callbacks *registry, void *ctxt, php_dom_xpath_callbacks_register_func_ctx register_func)
void xsl_ext_function_string_php(xmlXPathParserContextPtr ctxt, int nargs)
xsl_ns_hash_correction_status
@ XSL_NS_HASH_CORRECTION_FAILED
@ XSL_NS_HASH_CORRECTION_APPLIED
@ XSL_NS_HASH_CORRECTION_NONE
void xsl_ext_function_object_php(xmlXPathParserContextPtr ctxt, int nargs)
ZEND_API ZEND_COLD void zend_throw_error(zend_class_entry *exception_ce, const char *format,...)
Definition zend.c:1772
ZEND_API zend_result object_init_ex(zval *arg, zend_class_entry *class_type)
Definition zend_API.c:1849
ZEND_API zend_result zend_parse_parameters(uint32_t num_args, const char *type_spec,...)
Definition zend_API.c:1300
ZEND_API ZEND_COLD void zend_argument_value_error(uint32_t arg_num, const char *format,...)
Definition zend_API.c:433
ZEND_API void zend_release_fcall_info_cache(zend_fcall_info_cache *fcc)
Definition zend_API.c:3845
ZEND_API ZEND_COLD void zend_argument_type_error(uint32_t arg_num, const char *format,...)
Definition zend_API.c:423
#define Z_PARAM_PATH_STR(dest)
Definition zend_API.h:2041
#define CHECK_NULL_PATH(p, l)
Definition zend_API.h:950
#define ZEND_NUM_ARGS()
Definition zend_API.h:530
struct _zend_fcall_info_cache zend_fcall_info_cache
#define Z_PARAM_ARRAY_HT_OR_STR_OR_NULL(dest_ht, dest_str)
Definition zend_API.h:2154
#define ZEND_PARSE_PARAMETERS_END()
Definition zend_API.h:1641
#define RETURN_FALSE
Definition zend_API.h:1058
#define Z_PARAM_OPTIONAL
Definition zend_API.h:1667
#define zend_parse_parameters_none()
Definition zend_API.h:353
#define Z_PARAM_STRING(dest, dest_len)
Definition zend_API.h:2071
#define ZEND_PARSE_PARAMETERS_START(min_num_args, max_num_args)
Definition zend_API.h:1620
#define Z_PARAM_ARRAY_HT_OR_STR(dest_ht, dest_str)
Definition zend_API.h:2151
#define RETURN_LONG(l)
Definition zend_API.h:1037
struct _zend_fcall_info zend_fcall_info
#define RETURN_THROWS()
Definition zend_API.h:1060
#define RETVAL_TRUE
Definition zend_API.h:1033
#define ZEND_THIS
Definition zend_API.h:523
#define RETVAL_LONG(l)
Definition zend_API.h:1011
#define Z_PARAM_FUNC_NO_TRAMPOLINE_FREE(dest_fci, dest_fcc)
Definition zend_API.h:1827
#define RETURN_TRUE
Definition zend_API.h:1059
#define RETVAL_STRINGL(s, l)
Definition zend_API.h:1018
#define Z_PARAM_PATH_STR_OR_NULL(dest)
Definition zend_API.h:2044
#define RETURN_STR_COPY(s)
Definition zend_API.h:1042
#define efree(ptr)
Definition zend_alloc.h:155
#define emalloc(size)
Definition zend_alloc.h:151
struct _zval_struct zval
zend_string_release_ex(func->internal_function.function_name, 0)
#define BP_VAR_R
#define E_WARNING
Definition zend_errors.h:24
ZEND_API bool zend_is_executing(void)
ZEND_API zend_string * get_active_function_or_method_name(void)
#define EG(v)
ZEND_API zval *ZEND_FASTCALL zend_hash_update(HashTable *ht, zend_string *key, zval *pData)
Definition zend_hash.c:997
ZEND_API zend_result ZEND_FASTCALL zend_hash_del(HashTable *ht, zend_string *key)
Definition zend_hash.c:1534
ZEND_API zval *ZEND_FASTCALL zend_hash_find(const HashTable *ht, zend_string *key)
Definition zend_hash.c:2668
#define ZEND_HASH_FOREACH_STR_KEY_VAL(ht, _key, _val)
Definition zend_hash.h:1166
#define ZEND_HASH_FOREACH_END()
Definition zend_hash.h:1086
#define ZEND_HASH_MAP_FOREACH_STR_KEY_VAL(ht, _key, _val)
Definition zend_hash.h:1374
int32_t zend_long
Definition zend_long.h:42
struct _zend_string zend_string
ZEND_API zval * zend_std_read_property(zend_object *zobj, zend_string *name, int type, void **cache_slot, zval *rv)
ZEND_API bool ZEND_FASTCALL zend_is_true(const zval *op)
#define ZEND_DIAGNOSTIC_IGNORED_END
#define zend_always_inline
#define ZEND_ASSERT(c)
#define ZEND_DIAGNOSTIC_IGNORED_START(warning)
#define UNEXPECTED(condition)
struct _zend_class_entry zend_class_entry
#define ZSTR_VAL(zstr)
Definition zend_string.h:68
#define ZSTR_INIT_LITERAL(s, persistent)
#define zend_string_equals_literal(str, literal)
#define ZSTR_LEN(zstr)
Definition zend_string.h:69
#define Z_TYPE_P(zval_p)
Definition zend_types.h:660
#define ZVAL_STR(z, s)
#define Z_STRVAL_P(zval_p)
Definition zend_types.h:975
#define IS_STRING
Definition zend_types.h:606
#define ZVAL_STR_COPY(z, s)
struct _zend_array HashTable
Definition zend_types.h:386
#define Z_OBJ_P(zval_p)
Definition zend_types.h:990
#define Z_STR_P(zval_p)
Definition zend_types.h:972
#define Z_OBJCE_P(zval_p)
@ FAILURE
Definition zend_types.h:61
#define IS_LONG
Definition zend_types.h:604
ZEND_RESULT_CODE zend_result
Definition zend_types.h:64
#define Z_LVAL_P(zval_p)
Definition zend_types.h:966
#define VCWD_FOPEN(path, mode)
zval * return_value
zend_string * name
bool result
object
zval * ret
value
out($f, $s)