You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@xmlbeans.apache.org by ra...@apache.org on 2009/07/10 00:14:04 UTC
svn commit: r792729 - in
/xmlbeans/trunk/src/typeimpl/org/apache/xmlbeans/impl:
util/XsTypeConverter.java validator/Validator.java
Author: radup
Date: Thu Jul 9 22:14:04 2009
New Revision: 792729
URL: http://svn.apache.org/viewvc?rev=792729&view=rev
Log:
Incorporated anyURI stricter validation from revision 729009.
Modified:
xmlbeans/trunk/src/typeimpl/org/apache/xmlbeans/impl/util/XsTypeConverter.java
xmlbeans/trunk/src/typeimpl/org/apache/xmlbeans/impl/validator/Validator.java
Modified: xmlbeans/trunk/src/typeimpl/org/apache/xmlbeans/impl/util/XsTypeConverter.java
URL: http://svn.apache.org/viewvc/xmlbeans/trunk/src/typeimpl/org/apache/xmlbeans/impl/util/XsTypeConverter.java?rev=792729&r1=792728&r2=792729&view=diff
==============================================================================
--- xmlbeans/trunk/src/typeimpl/org/apache/xmlbeans/impl/util/XsTypeConverter.java (original)
+++ xmlbeans/trunk/src/typeimpl/org/apache/xmlbeans/impl/util/XsTypeConverter.java Thu Jul 9 22:14:04 2009
@@ -761,11 +761,17 @@
} */
// Per XMLSchema spec allow spaces inside URIs
- String s = lexical_value.toString().replace(" ", "%20");
+ StringBuffer s = new StringBuffer(lexical_value.toString());
+ int i = 0;
+ while ((i = s.indexOf(" ", i)) >= 0)
+ {
+ s.replace(i, i + 1, "%20");
+ i += 3;
+ }
try
{
- URI.create(s);
+ URI.create(s.toString());
}
catch (IllegalArgumentException e)
{
@@ -774,67 +780,4 @@
return lexical_value;
}
-
-// public static void main(String[] args)
-// {
-// lexAnyURI("http://www.ics.uci.edu/pub/ietf/uri/#Related");
-// lexAnyURI("http://www.ics.uci.edu/pub/ietf/uri/?query=abc#Related");
-// lexAnyURI("http://a/b/c/d;p?q");
-// lexAnyURI("g:h");
-// lexAnyURI("./g");
-// lexAnyURI("g/");
-// lexAnyURI("/g");
-// lexAnyURI("//g");
-// lexAnyURI("?y");
-// lexAnyURI("g?y");
-// lexAnyURI("#s");
-// lexAnyURI("g#s");
-// lexAnyURI("g?y#s");
-// lexAnyURI(";x");
-// lexAnyURI("g;x");
-// lexAnyURI("g;x?y#s");
-// lexAnyURI(".");
-// lexAnyURI("./");
-// lexAnyURI("..");
-// lexAnyURI("../");
-// lexAnyURI("../g");
-// lexAnyURI("../..");
-// lexAnyURI("../../");
-// lexAnyURI("../../g");
-//
-// lexAnyURI("http:// www .ics.uci.edu /pub/ietf/uri /#Related");
-// lexAnyURI("http:// www .ics.uci.edu /pub/iet%20%20f/uri /#Related");
-//
-//
-// // From XQTS cvshead June 2009
-// String[] invalidURIs = {"http:\\\\invalid>URI\\someURI", // K2-SeqExprCast-207: Construct an xs:anyURI from an invalid string. However, in F&O 17.1.1, it is said that "For xs:anyURI, the extent to which an implementation validates the lexical form of xs:anyURI is implementation dependent.".
-// "http://www.example.com/file%GF.html", // K2-SeqExprCast-210: '%' is not a disallowed character and therefore it's not encoded before being considered for RFC 2396 validness.
-// "foo://", // K2-SeqExprCast-421: Pass an invalid anyURI.
-// "foo:", // K2-SeqExprCast-421-2: Pass an invalid anyURI.
-// "%gg", // K2-SeqExprCast-422: Pass an invalid anyURI(#2).
-// ":/cut.jpg", // K2-SeqExprCast-423: no scheme
-// ":/images/cut.png", // K2-SeqExprCast-424: An URI without scheme, combined with a relative directory.
-// ":/", // K2-SeqExprCast-505: ':/' is an invalid URI, no scheme.
-// "http:%%", // fn-resolve-uri-4: Evaluation of resolve-uri function with an invalid URI value for second argument.
-// ":", // fn-resolve-uri-3: Evaluation of resolve-uri function with an invalid URI value for first argument.
-// "###Rel",
-// "##",
-// "????###",
-// "###????"
-// };
-//
-// for ( int i = 0; i < invalidURIs.length ; i++ )
-// {
-// try
-// {
-// lexAnyURI(invalidURIs[i]);
-// throw new IllegalStateException("URI should be invalid: " + invalidURIs[i]);
-// }
-// catch (InvalidLexicalValueException e)
-// {
-// System.out.println("URI invalid: " + invalidURIs[i] + " " + e.getCause().getCause().getMessage());
-// assert true;
-// }
-// }
-// }
}
\ No newline at end of file
Modified: xmlbeans/trunk/src/typeimpl/org/apache/xmlbeans/impl/validator/Validator.java
URL: http://svn.apache.org/viewvc/xmlbeans/trunk/src/typeimpl/org/apache/xmlbeans/impl/validator/Validator.java?rev=792729&r1=792728&r2=792729&view=diff
==============================================================================
--- xmlbeans/trunk/src/typeimpl/org/apache/xmlbeans/impl/validator/Validator.java (original)
+++ xmlbeans/trunk/src/typeimpl/org/apache/xmlbeans/impl/validator/Validator.java Thu Jul 9 22:14:04 2009
@@ -20,6 +20,7 @@
import org.apache.xmlbeans.impl.common.ValidationContext;
import org.apache.xmlbeans.impl.common.ValidatorListener;
import org.apache.xmlbeans.impl.common.XmlWhitespace;
+import org.apache.xmlbeans.impl.common.InvalidLexicalValueException;
import org.apache.xmlbeans.impl.schema.SchemaTypeVisitorImpl;
import org.apache.xmlbeans.impl.schema.SchemaTypeImpl;
import org.apache.xmlbeans.impl.schema.BuiltinSchemaTypeSystem;
@@ -40,6 +41,7 @@
import org.apache.xmlbeans.impl.values.XmlListImpl;
import org.apache.xmlbeans.impl.values.XmlQNameImpl;
import org.apache.xmlbeans.impl.values.XmlValueOutOfRangeException;
+import org.apache.xmlbeans.impl.util.XsTypeConverter;
import org.apache.xmlbeans.GDate;
import org.apache.xmlbeans.GDuration;
import org.apache.xmlbeans.QNameSet;
@@ -1348,6 +1350,18 @@
case SchemaType.BTC_ANY_URI :
{
JavaUriHolderEx.validateLexical( value, type, _vc );
+ // Do strict validation
+ if (_strict)
+ {
+ try
+ {
+ XsTypeConverter.lexAnyURI( value );
+ }
+ catch (InvalidLexicalValueException ilve)
+ {
+ _vc.invalid(XmlErrorCodes.ANYURI, new Object[] { value });
+ }
+ }
_stringValue = value;
break;
}
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@xmlbeans.apache.org
For additional commands, e-mail: commits-help@xmlbeans.apache.org