@@ -347,7 +347,8 @@ End Enum
347
347
' @param FormUrlEncoding ALPHA / DIGIT / "-" / "." / "_" / "*", (space) -> "+", &...; UTF-8 encoding
348
348
' @param QueryUrlEncoding Subset of strict and form that should be suitable for non-form-urlencoded query strings
349
349
' ALPHA / DIGIT / "-" / "." / "_"
350
- ' @param CookieUrlEncoding strict / "!" / "#" / "$" / "%" / "&" / "'" / "*" / "+" / "^" / "`" / "|"
350
+ ' @param CookieUrlEncoding strict / "!" / "#" / "$" / "&" / "'" / "(" / ")" / "*" / "+" /
351
+ ' "/" / ":" / "<" / "=" / ">" / "?" / "@" / "[" / "]" / "^" / "`" / "{" / "|" / "}"
351
352
' @param PathUrlEncoding strict / "!" / "$" / "&" / "'" / "(" / ")" / "*" / "+" / "," / ";" / "=" / ":" / "@"
352
353
''
353
354
Public Enum UrlEncodingMode
@@ -833,6 +834,7 @@ End Function
833
834
' - form-urlencoded encoding algorithm,
834
835
' https://www.w3.org/TR/html5/forms.html#application/x-www-form-urlencoded-encoding-algorithm
835
836
' - RFC 6265 (Cookies), https://tools.ietf.org/html/rfc6265
837
+ ' Note: "%" is allowed in spec, but is currently excluded due to parsing issues
836
838
'
837
839
' @method UrlEncode
838
840
' @param {Variant} Text Text to encode
@@ -875,7 +877,8 @@ Public Function UrlEncode(Text As Variant, _
875
877
' StrictUrlEncoding - ALPHA / DIGIT / "-" / "." / "_" / "~"
876
878
' FormUrlEncoding - ALPHA / DIGIT / "-" / "." / "_" / "*" / (space) -> "+"
877
879
' QueryUrlEncoding - ALPHA / DIGIT / "-" / "." / "_"
878
- ' CookieUrlEncoding - strict / "!" / "#" / "$" / "%" / "&" / "'" / "*" / "+" / "^" / "`" / "|"
880
+ ' CookieUrlEncoding - strict / "!" / "#" / "$" / "&" / "'" / "(" / ")" / "*" / "+" /
881
+ ' "/" / ":" / "<" / "=" / ">" / "?" / "@" / "[" / "]" / "^" / "`" / "{" / "|" / "}"
879
882
' PathUrlEncoding - strict / "!" / "$" / "&" / "'" / "(" / ")" / "*" / "+" / "," / ";" / "=" / ":" / "@"
880
883
881
884
' Set space value
@@ -908,33 +911,26 @@ Public Function UrlEncode(Text As Variant, _
908
911
' Else -> "%20"
909
912
web_Result(web_i) = web_Space
910
913
911
- Case 33 , 36 , 38 , 39 , 43
912
- ' "!" / "$" / "&" / "'" / "+ "
914
+ Case 33 , 36 , 38 , 39 , 40 , 41 , 43 , 58 , 61 , 64
915
+ ' "!" / "$" / "&" / "'" / "(" / ")" / "+" / ":" / "=" / "@ "
913
916
' PathUrlEncoding, CookieUrlEncoding -> Unencoded
914
917
' Else -> Percent-encoded
915
918
If EncodingMode = UrlEncodingMode.PathUrlEncoding Or EncodingMode = UrlEncodingMode.CookieUrlEncoding Then
916
919
web_Result(web_i) = web_Char
917
920
Else
918
921
web_Result(web_i) = "%" & VBA.Hex(web_CharCode)
919
922
End If
920
- Case 35 , 94 , 96 , 124
921
- ' "#" / "^" / "`" / "|"
923
+
924
+ Case 35 , 45 , 46 , 47 , 60 , 62 , 63 , 91 , 93 , 94 , 95 , 96 , 123 , 124 , 125
925
+ ' "#" / "-" / "." / "/" / "<" / ">" / "?" / "[" / "]" / "^" / "_" / "`" / "{" / "|" / "}"
922
926
' CookieUrlEncoding -> Unencoded
923
927
' Else -> Percent-encoded
924
928
If EncodingMode = UrlEncodingMode.CookieUrlEncoding Then
925
929
web_Result(web_i) = web_Char
926
930
Else
927
931
web_Result(web_i) = "%" & VBA.Hex(web_CharCode)
928
932
End If
929
- Case 40 , 41 , 44 , 58 , 59 , 61 , 64
930
- ' "(" / ")" / "," / ":" / ";" / "=" / "@"
931
- ' PathUrlEncoding -> Unencoded
932
- ' Else -> Percent-encoded
933
- If EncodingMode = UrlEncodingMode.PathUrlEncoding Then
934
- web_Result(web_i) = web_Char
935
- Else
936
- web_Result(web_i) = "%" & VBA.Hex(web_CharCode)
937
- End If
933
+
938
934
Case 42
939
935
' "*"
940
936
' FormUrlEncoding, PathUrlEncoding, CookieUrlEncoding -> "*"
@@ -947,6 +943,17 @@ Public Function UrlEncode(Text As Variant, _
947
943
Else
948
944
web_Result(web_i) = "%" & VBA.Hex(web_CharCode)
949
945
End If
946
+
947
+ Case 44 , 59
948
+ ' "," / ";"
949
+ ' PathUrlEncoding -> Unencoded
950
+ ' Else -> Percent-encoded
951
+ If EncodingMode = UrlEncodingMode.PathUrlEncoding Then
952
+ web_Result(web_i) = web_Char
953
+ Else
954
+ web_Result(web_i) = "%" & VBA.Hex(web_CharCode)
955
+ End If
956
+
950
957
Case 126
951
958
' "~"
952
959
' FormUrlEncoding, QueryUrlEncoding -> "%7E"
@@ -956,6 +963,7 @@ Public Function UrlEncode(Text As Variant, _
956
963
Else
957
964
web_Result(web_i) = web_Char
958
965
End If
966
+
959
967
Case 0 To 15
960
968
web_Result(web_i) = "%0" & VBA.Hex(web_CharCode)
961
969
Case Else
0 commit comments