dbertoni    2003/03/12 17:00:33

  Modified:    c/src/XSLT FunctionSystemProperty.cpp
  Log:
  Fix for Bugzilla 17938.
  
  Revision  Changes    Path
  1.28      +36 -27    xml-xalan/c/src/XSLT/FunctionSystemProperty.cpp
  
  Index: FunctionSystemProperty.cpp
  ===================================================================
  RCS file: /home/cvs/xml-xalan/c/src/XSLT/FunctionSystemProperty.cpp,v
  retrieving revision 1.27
  retrieving revision 1.28
  diff -u -r1.27 -r1.28
  --- FunctionSystemProperty.cpp        27 Jan 2003 17:26:40 -0000      1.27
  +++ FunctionSystemProperty.cpp        13 Mar 2003 01:00:32 -0000      1.28
  @@ -69,6 +69,7 @@
   
   #include <XPath/MutableNodeRefList.hpp>
   #include <XPath/NodeRefListBase.hpp>
  +#include <XPath/XalanQName.hpp>
   #include <XPath/XObjectFactory.hpp>
   
   
  @@ -77,6 +78,10 @@
   
   
   
  +static const XalanDOMString          s_emptyString;
  +
  +
  +
   FunctionSystemProperty::FunctionSystemProperty() :
        Function(),
        
m_xsltNamespaceURI(XALAN_STATIC_UCODE_STRING("http://www.w3.org/1999/XSL/Transform";)),
  @@ -96,10 +101,28 @@
   
   
   
  +inline void
  +validateNCName(
  +                     XPathExecutionContext&  executionContext,
  +                     XalanNode*                              context,
  +                     const LocatorType*              locator,
  +                     const XalanDOMString&   ncname)
  +{
  +     if (XalanQName::isValidNCName(ncname) == false)
  +     {
  +             executionContext.error(
  +                     "system-property(): The property is not a valid QName",
  +                     context,
  +                     locator);
  +     }
  +}
  +
  +
  +
   XObjectPtr
   FunctionSystemProperty::execute(
                        XPathExecutionContext&  executionContext,
  -                     XalanNode*                              context,        
                
  +                     XalanNode*                              context,
                        const XObjectPtr                arg1,
                        const LocatorType*              locator) const
   {
  @@ -117,6 +140,8 @@
   
                substring(fullName, theBuffer, 0, indexOfNSSep);
   
  +             validateNCName(executionContext, context, locator, theBuffer);
  +
                const XalanDOMString* const             nspace = 
executionContext.getNamespaceForPrefix(theBuffer);
   
                if (nspace == 0)
  @@ -128,10 +153,12 @@
                }
                else
                {
  -                     substring(fullName, theBuffer, indexOfNSSep + 1);
  -
  -                     if(startsWith(*nspace, m_xsltNamespaceURI))
  +                     if(*nspace == m_xsltNamespaceURI)
                        {
  +                             substring(fullName, theBuffer, indexOfNSSep + 
1);
  +
  +                             validateNCName(executionContext, context, 
locator, theBuffer);
  +
                                if(equals(theBuffer, m_versionPropertyString))
                                {
                                        return 
executionContext.getXObjectFactory().createNumber(1.0);
  @@ -146,23 +173,15 @@
                                }
                                else
                                {
  -                                     executionContext.error(
  -                                             "Unknown property in 
system-property()",
  -                                             context,
  -                                             locator);
  +                                     return 
executionContext.getXObjectFactory().createStringReference(s_emptyString);
                                }
                        }
  -                     else
  -                     {
  -                             executionContext.warn(
  -                                     "Only the XSLT namespace is supported 
in the function system-property()",
  -                                     context,
  -                                     locator);
  -                     }
                }
        }
        else
        {
  +             validateNCName(executionContext, context, locator, fullName);
  +
                const char* const       theEnvString =
   #if defined(XALAN_STRICT_ANSI_HEADERS)
                        std::getenv(c_str(TranscodeToLocalCodePage(fullName)));
  @@ -170,14 +189,7 @@
                        getenv(c_str(TranscodeToLocalCodePage(fullName)));
   #endif
   
  -             if (theEnvString == 0)
  -             {
  -                             executionContext.warn(
  -                                     "Unknown environment proprerty 
requested",
  -                                     context,
  -                                     locator);
  -             }
  -             else
  +             if (theEnvString != 0)
                {
                        XPathExecutionContext::GetAndReleaseCachedString        
guard(executionContext);
   
  @@ -189,10 +201,7 @@
                }
        }
   
  -     // We should never get here...
  -     assert(false);
  -
  -     return XObjectPtr();
  +     return 
executionContext.getXObjectFactory().createStringReference(s_emptyString);
   }
   
   
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to