aboutsummaryrefslogtreecommitdiff
path: root/src/PercentEncodedCharacterDecoder.cpp
diff options
context:
space:
mode:
authorRichard Walters <rwalters@digitalstirling.com>2018-07-01 23:36:07 -0700
committerRichard Walters <rwalters@digitalstirling.com>2018-07-01 23:36:07 -0700
commit432a413f585c834d7ecd69a46443a33af40f79db (patch)
treee73f714ce722761c7482870a1acbb7dc81ffaa24 /src/PercentEncodedCharacterDecoder.cpp
parent4c662109404c79440a62888ae8babff81ce1b71e (diff)
Allow HEXDIG to include lower-case 'a'..'f'
Diffstat (limited to 'src/PercentEncodedCharacterDecoder.cpp')
-rw-r--r--src/PercentEncodedCharacterDecoder.cpp16
1 files changed, 13 insertions, 3 deletions
diff --git a/src/PercentEncodedCharacterDecoder.cpp b/src/PercentEncodedCharacterDecoder.cpp
index 890d392..dc7cd58 100644
--- a/src/PercentEncodedCharacterDecoder.cpp
+++ b/src/PercentEncodedCharacterDecoder.cpp
@@ -21,7 +21,13 @@ namespace {
* This is the character set containing just the upper-case
* letters 'A' through 'F', used in upper-case hexadecimal.
*/
- const Uri::CharacterSet HEX('A', 'F');
+ const Uri::CharacterSet HEX_UPPER('A', 'F');
+
+ /**
+ * This is the character set containing just the lower-case
+ * letters 'a' through 'f', used in lower-case hexadecimal.
+ */
+ const Uri::CharacterSet HEX_LOWER('a', 'f');
}
@@ -58,8 +64,10 @@ namespace Uri {
impl_->decodedCharacter <<= 4;
if (IsCharacterInSet(c, DIGIT)) {
impl_->decodedCharacter += (int)(c - '0');
- } else if (IsCharacterInSet(c, HEX)) {
+ } else if (IsCharacterInSet(c, HEX_UPPER)) {
impl_->decodedCharacter += (int)(c - 'A') + 10;
+ } else if (IsCharacterInSet(c, HEX_LOWER)) {
+ impl_->decodedCharacter += (int)(c - 'a') + 10;
} else {
return false;
}
@@ -70,8 +78,10 @@ namespace Uri {
impl_->decodedCharacter <<= 4;
if (IsCharacterInSet(c, DIGIT)) {
impl_->decodedCharacter += (int)(c - '0');
- } else if (IsCharacterInSet(c, HEX)) {
+ } else if (IsCharacterInSet(c, HEX_UPPER)) {
impl_->decodedCharacter += (int)(c - 'A') + 10;
+ } else if (IsCharacterInSet(c, HEX_LOWER)) {
+ impl_->decodedCharacter += (int)(c - 'a') + 10;
} else {
return false;
}