/[svn]/php/php-src/branches/PHP_5_3/ext/xsl/xsltprocessor.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 317758 by felipe, Sat Jan 1 02:19:59 2011 UTC revision 317759 by chregu, Wed Oct 5 09:56:01 2011 UTC
# Line 475  static xmlDocPtr php_xsl_apply_styleshee Line 475  static xmlDocPtr php_xsl_apply_styleshee
475          zval *doXInclude, *member;          zval *doXInclude, *member;
476          zend_object_handlers *std_hnd;          zend_object_handlers *std_hnd;
477          FILE *f;          FILE *f;
478            int secPrefsError;
479            int secPrefsIni;
480            xsltSecurityPrefsPtr secPrefs = NULL;
481    
482          node = php_libxml_import_node(docp TSRMLS_CC);          node = php_libxml_import_node(docp TSRMLS_CC);
483                    
# Line 531  static xmlDocPtr php_xsl_apply_styleshee Line 534  static xmlDocPtr php_xsl_apply_styleshee
534          }          }
535          efree(member);          efree(member);
536    
537          newdocp = xsltApplyStylesheetUser(style, doc, (const char**) params,  NULL, f, ctxt);          
538            secPrefsIni = INI_INT("xsl.security_prefs");
539            
540            //if securityPrefs is set to NONE, we don't have to do any checks, but otherwise...
541            if (secPrefsIni != XSL_SECPREF_NONE) {
542                    secPrefs = xsltNewSecurityPrefs();
543                    if (secPrefsIni & XSL_SECPREF_READ_FILE ) {
544                            if (0 != xsltSetSecurityPrefs(secPrefs, XSLT_SECPREF_READ_FILE, xsltSecurityForbid)) {
545                                    secPrefsError = 1;
546                            }
547                    }
548                    if (secPrefsIni & XSL_SECPREF_WRITE_FILE ) {
549                            if (0 != xsltSetSecurityPrefs(secPrefs, XSLT_SECPREF_WRITE_FILE, xsltSecurityForbid)) {
550                                    secPrefsError = 1;
551                            }
552                    }
553                    if (secPrefsIni & XSL_SECPREF_CREATE_DIRECTORY ) {
554                            if (0 != xsltSetSecurityPrefs(secPrefs, XSLT_SECPREF_CREATE_DIRECTORY, xsltSecurityForbid)) {
555                                    secPrefsError = 1;
556                            }
557                    }
558                    if (secPrefsIni & XSL_SECPREF_READ_NETWORK) {
559                            if (0 != xsltSetSecurityPrefs(secPrefs, XSLT_SECPREF_READ_NETWORK, xsltSecurityForbid)) {
560                                    secPrefsError = 1;
561                            }
562                    }
563                    if (secPrefsIni & XSL_SECPREF_WRITE_NETWORK) {
564                            if (0 != xsltSetSecurityPrefs(secPrefs, XSLT_SECPREF_WRITE_NETWORK, xsltSecurityForbid)) {
565                                    secPrefsError = 1;
566                            }
567                    }
568            
569                    if (0 != xsltSetCtxtSecurityPrefs(secPrefs, ctxt)) {
570                            secPrefsError = 1;
571                    }
572            }
573            
574            if (secPrefsError == 1) {
575                    php_error_docref(NULL TSRMLS_CC, E_WARNING, "Can't set libxslt security properties, not doing transformation for security reasons");
576            } else {
577                    newdocp = xsltApplyStylesheetUser(style, doc, (const char**) params,  NULL, f, ctxt);
578            }
579          if (f) {          if (f) {
580                  fclose(f);                  fclose(f);
581          }          }
582            
583          xsltFreeTransformContext(ctxt);          xsltFreeTransformContext(ctxt);
584            if (secPrefs) {
585                    xsltFreeSecurityPrefs(secPrefs);
586            }
587    
588          if (intern->node_list != NULL) {          if (intern->node_list != NULL) {
589                  zend_hash_destroy(intern->node_list);                  zend_hash_destroy(intern->node_list);

Legend:
Removed from v.317758  
changed lines
  Added in v.317759