Permalink
Browse files

Fixes issue 118 - The test for unescaping a unicode character at the …

…end of the string was incorrect, which meant JSONTokenizer was incorrectly generating an error in this particular case. Both the test and the tokenizer have been fixed.
  • Loading branch information...
1 parent 5525fe2 commit 7b8b05bfb9cfe88dbaa51ca2b9e28506f074693e @darronschall darronschall committed Aug 24, 2009
@@ -287,8 +287,7 @@ package com.adobe.serialization.json {
/**
* Convert all JavaScript escape characters into normal characters
*
- * @param source A source string to convert
- *
+ * @param input The input string to convert
* @return Original string with escape characters replaced by real characters
*/
public function unescapeString( input:String ):String
@@ -306,7 +305,7 @@ package com.adobe.serialization.json {
var len:int = input.length;
do
{
- // Find the next backslask in the input
+ // Find the next backslash in the input
backslashIndex = input.indexOf( '\\', nextSubstringStartPosition );
if ( backslashIndex >= 0 )
@@ -337,7 +336,7 @@ package com.adobe.serialization.json {
var hexValue:String = "";
// Make sure there are enough characters in the string leftover
- if ( nextSubstringStartPosition + 4 >= len )
+ if ( nextSubstringStartPosition + 4 > len )
{
parseError( "Unexpected end of input. Expecting 4 hex digits after \\u." );
}
@@ -679,19 +678,13 @@ package com.adobe.serialization.json {
}
/**
- * Determines if a character is a digit [0-9].
+ * Determines if a character is a hex digit [0-9A-Fa-f].
*
- * @return True if the character passed in is a digit
+ * @return True if the character passed in is a hex digit
*/
private function isHexDigit( ch:String ):Boolean
{
- // get the uppercase value of ch so we only have
- // to compare the value between 'A' and 'F'
- var uc:String = ch.toUpperCase();
-
- // a hex digit is a digit of A-F, inclusive ( using
- // our uppercase constraint )
- return ( isDigit( ch ) || ( uc >= 'A' && uc <= 'F' ) );
+ return ( isDigit( ch ) || ( ch >= 'A' && ch <= 'F' ) || ( ch >= 'a' && ch <= 'z' ) );
}
/**
@@ -37,7 +37,7 @@
xmlns:flexunit="flexunit.flexui.*"
creationComplete="onCreationComplete()">
- <mx:Script source="CoreLibTestRunner.as" />
+ <mx:Script source="CoreLibTestRunner_script.as" />
<mx:Canvas width="100%" height="100%">
<flexunit:TestRunnerBase id="testRunner" width="100%" height="100%" />
@@ -0,0 +1,138 @@
+/*
+ Copyright (c) 2008, Adobe Systems Incorporated
+ All rights reserved.
+
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions are
+ met:
+
+ * Redistributions of source code must retain the above copyright notice,
+ this list of conditions and the following disclaimer.
+
+ * Redistributions in binary form must reproduce the above copyright
+ notice, this list of conditions and the following disclaimer in the
+ documentation and/or other materials provided with the distribution.
+
+ * Neither the name of Adobe Systems Incorporated nor the names of its
+ contributors may be used to endorse or promote products derived from
+ this software without specific prior written permission.
+
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
+ IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+ CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+*/
+
+import com.adobe.air.crypto.EncryptionKeyGeneratorTest;
+import com.adobe.crypto.HMACMD5Test;
+import com.adobe.crypto.HMACSHA1Test;
+import com.adobe.crypto.MD5Test;
+import com.adobe.crypto.SHA1Test;
+import com.adobe.crypto.SHA224Test;
+import com.adobe.crypto.SHA256Test;
+import com.adobe.crypto.WSSEUsernameTokenTest;
+import com.adobe.images.JPGEncoderTest;
+import com.adobe.images.PNGEncoderTest;
+import com.adobe.net.URITest;
+import com.adobe.serialization.json.JSONTest;
+import com.adobe.utils.ArrayUtilTest;
+import com.adobe.utils.DateUtilTest;
+import com.adobe.utils.DictionaryUtilTest;
+import com.adobe.utils.IntUtilTest;
+import com.adobe.utils.NumberFormatterTest;
+import com.adobe.utils.StringUtilTest;
+import com.adobe.utils.XMLUtilTest;
+
+import flexunit.framework.TestSuite;
+import com.adobe.air.filesystem.VolumeMonitorTest;
+import com.adobe.air.filesystem.events.FileMonitorEventTest;
+import com.adobe.air.net.events.ResourceCacheEventTest;
+import com.adobe.protocols.events.ConnectedEventTest;
+import com.adobe.protocols.events.DatabaseEventTest;
+import com.adobe.protocols.events.DefinitionEventTest;
+import com.adobe.protocols.events.DefinitionHeaderEventTest;
+import com.adobe.protocols.events.DictionaryServerEventTest;
+import com.adobe.protocols.events.DisconnectedEventTest;
+import com.adobe.protocols.events.ErrorEventTest;
+import com.adobe.protocols.events.MatchEventTest;
+import com.adobe.protocols.events.MatchStrategiesEventTest;
+import com.adobe.protocols.events.NoMatchEventTest;
+import com.adobe.protocols.util.CompletedResponseEventTest;
+import com.adobe.webapis.events.ServiceEventTest;
+import com.adobe.air.filesystem.FileMonitorTest;
+
+
+private function onCreationComplete():void
+{
+ testRunner.test = createSuite();
+ testRunner.startTest();
+}
+
+private function createSuite():TestSuite
+{
+ var ts:TestSuite = new TestSuite();
+
+ // utils
+// ts.addTestSuite( StringUtilTest );
+// ts.addTestSuite( NumberFormatterTest );
+// ts.addTestSuite( ArrayUtilTest );
+// ts.addTestSuite( DateUtilTest );
+// ts.addTestSuite( IntUtilTest );
+// ts.addTestSuite( XMLUtilTest );
+// ts.addTestSuite( DictionaryUtilTest );
+//
+// // crypto
+// ts.addTestSuite( HMACSHA1Test );
+// ts.addTestSuite( HMACMD5Test );
+// ts.addTestSuite( MD5Test );
+// ts.addTestSuite( SHA1Test );
+// ts.addTestSuite( SHA224Test );
+// ts.addTestSuite( SHA256Test );
+// ts.addTestSuite( WSSEUsernameTokenTest );
+//
+// // net
+// ts.addTestSuite( URITest );
+//
+ // serialization
+ ts.addTestSuite( JSONTest );
+
+// //images
+// ts.addTestSuite( JPGEncoderTest );
+// ts.addTestSuite( PNGEncoderTest );
+//
+ //protocols.dict
+ ts.addTestSuite(ConnectedEventTest);
+ ts.addTestSuite(DatabaseEventTest);
+ ts.addTestSuite(DefinitionEventTest);
+ ts.addTestSuite(DefinitionHeaderEventTest);
+ ts.addTestSuite(DictionaryServerEventTest);
+ ts.addTestSuite(DisconnectedEventTest);
+ ts.addTestSuite(ErrorEventTest);
+ ts.addTestSuite(MatchEventTest);
+ ts.addTestSuite(MatchStrategiesEventTest);
+ ts.addTestSuite(NoMatchEventTest);
+ ts.addTestSuite(CompletedResponseEventTest);
+
+ //webapis
+ ts.addTestSuite(ServiceEventTest);
+
+ // air.crypto
+ ts.addTestSuite( EncryptionKeyGeneratorTest );
+
+ //air.filesystem
+ ts.addTestSuite(VolumeMonitorTest);
+ ts.addTestSuite(FileMonitorTest);
+ ts.addTestSuite(FileMonitorEventTest);
+
+ //air.net
+ ts.addTestSuite(ResourceCacheEventTest);
+
+ return ts;
+}

0 comments on commit 7b8b05b

Please sign in to comment.