Skip to content

Commit 3e073ec

Browse files
committed
trim validated URLs
1 parent 1fb0856 commit 3e073ec

1 file changed

Lines changed: 7 additions & 3 deletions

File tree

FlashpointSecurePlayer/Shared.cs

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1987,6 +1987,8 @@ public string this[string shortPath] {
19871987
private const string URI_SCHEME_FTP = "ftp";
19881988

19891989
public static string GetValidatedURL(string url) {
1990+
url = url.Trim();
1991+
19901992
// first try a guessed scheme
19911993
// (for example, guess HTTP for www subdomain, FTP for ftp subdomain...)
19921994
StringBuilder validatedURL = new StringBuilder((int)INTERNET_MAX_URL_LENGTH);
@@ -1999,7 +2001,7 @@ public static string GetValidatedURL(string url) {
19992001
url = validatedURL.ToString();
20002002
} else {
20012003
// second try the default scheme
2002-
// we only do this to see if it returns S_FALSE
2004+
// we only do this to see if it returns S_FALSE, because
20032005
// if so, we know there is already a scheme and don't add our own
20042006
// we do not use the validated URL given by UrlApplyScheme here
20052007
validatedURL.Clear();
@@ -2011,8 +2013,10 @@ public static string GetValidatedURL(string url) {
20112013
// (in case the default is HTTPS)
20122014
if (err != S_FALSE) {
20132015
// skip leading slashes for protocol-less URLs
2014-
if (url.StartsWith("//", StringComparison.Ordinal)) {
2015-
url = url.Substring(2);
2016+
const string LEADING_SLASHES = "//";
2017+
2018+
if (url.StartsWith(LEADING_SLASHES, StringComparison.Ordinal)) {
2019+
url = url.Substring(LEADING_SLASHES.Length);
20162020
}
20172021

20182022
url = URI_SCHEME_HTTP + "://" + url;

0 commit comments

Comments
 (0)