@@ -1680,7 +1680,7 @@ private Token ScanFlowScalar(bool isSingleQuoted)
1680
1680
1681
1681
if ( codeLength > 0 )
1682
1682
{
1683
- uint character = 0 ;
1683
+ int character = 0 ;
1684
1684
1685
1685
// Scan the character value.
1686
1686
@@ -1690,7 +1690,7 @@ private Token ScanFlowScalar(bool isSingleQuoted)
1690
1690
{
1691
1691
throw new SyntaxErrorException ( start , cursor . Mark ( ) , "While parsing a quoted scalar, did not find expected hexdecimal number." ) ;
1692
1692
}
1693
- character = ( uint ) ( ( character << 4 ) + analyzer . AsHex ( k ) ) ;
1693
+ character = ( ( character << 4 ) + analyzer . AsHex ( k ) ) ;
1694
1694
}
1695
1695
1696
1696
// Check the value and write the character.
@@ -1700,7 +1700,7 @@ private Token ScanFlowScalar(bool isSingleQuoted)
1700
1700
throw new SyntaxErrorException ( start , cursor . Mark ( ) , "While parsing a quoted scalar, find invalid Unicode character escape code." ) ;
1701
1701
}
1702
1702
1703
- value . Append ( ( char ) character ) ;
1703
+ value . Append ( char . ConvertFromUtf32 ( character ) ) ;
1704
1704
1705
1705
// Advance the pointer.
1706
1706
@@ -2145,6 +2145,11 @@ private string ScanTagUri(string head, Mark start)
2145
2145
{
2146
2146
tag . Append ( ScanUriEscapes ( start ) ) ;
2147
2147
}
2148
+ else if ( analyzer . Check ( '+' ) )
2149
+ {
2150
+ tag . Append ( ' ' ) ;
2151
+ Skip ( ) ;
2152
+ }
2148
2153
else
2149
2154
{
2150
2155
tag . Append ( ReadCurrentCharacter ( ) ) ;
@@ -2165,11 +2170,12 @@ private string ScanTagUri(string head, Mark start)
2165
2170
/// Decode an URI-escape sequence corresponding to a single UTF-8 character.
2166
2171
/// </summary>
2167
2172
2168
- private char ScanUriEscapes ( Mark start )
2173
+ private string ScanUriEscapes ( Mark start )
2169
2174
{
2170
2175
// Decode the required number of characters.
2171
2176
2172
- var charBytes = new List < byte > ( ) ;
2177
+ byte [ ] charBytes = null ;
2178
+ int nextInsertionIndex = 0 ;
2173
2179
int width = 0 ;
2174
2180
do
2175
2181
{
@@ -2197,6 +2203,8 @@ private char ScanUriEscapes(Mark start)
2197
2203
{
2198
2204
throw new SyntaxErrorException ( start , cursor . Mark ( ) , "While parsing a tag, find an incorrect leading UTF-8 octet." ) ;
2199
2205
}
2206
+
2207
+ charBytes = new byte [ width ] ;
2200
2208
}
2201
2209
else
2202
2210
{
@@ -2210,22 +2218,22 @@ private char ScanUriEscapes(Mark start)
2210
2218
2211
2219
// Copy the octet and move the pointers.
2212
2220
2213
- charBytes . Add ( ( byte ) octet ) ;
2221
+ charBytes [ nextInsertionIndex ++ ] = ( byte ) octet ;
2214
2222
2215
2223
Skip ( ) ;
2216
2224
Skip ( ) ;
2217
2225
Skip ( ) ;
2218
2226
}
2219
2227
while ( -- width > 0 ) ;
2220
2228
2221
- var characters = Encoding . UTF8 . GetChars ( charBytes . ToArray ( ) ) ;
2229
+ var result = Encoding . UTF8 . GetString ( charBytes , 0 , nextInsertionIndex ) ;
2222
2230
2223
- if ( characters . Length != 1 )
2231
+ if ( result . Length == 0 || result . Length > 2 )
2224
2232
{
2225
2233
throw new SyntaxErrorException ( start , cursor . Mark ( ) , "While parsing a tag, find an incorrect UTF-8 sequence." ) ;
2226
2234
}
2227
2235
2228
- return characters [ 0 ] ;
2236
+ return result ;
2229
2237
}
2230
2238
2231
2239
/// <summary>
0 commit comments