mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-07-31 17:39:05 +00:00
Changed URL generation to use Kev's encode method rather than the Java URL encoder
(used a copy of the code to prevent adding a dependency on the web-client). git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@2084 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -424,22 +424,9 @@ public class WebDAV
|
||||
if ( isCollection && urlStr.charAt( urlStr.length() - 1) != PathSeperatorChar)
|
||||
urlStr.append( PathSeperator);
|
||||
|
||||
// Encode the URL
|
||||
|
||||
String encUrlStr = null;
|
||||
|
||||
try
|
||||
{
|
||||
encUrlStr = URLEncoder.encode( urlStr.toString(), "UTF-8");
|
||||
}
|
||||
catch (UnsupportedEncodingException ex)
|
||||
{
|
||||
logger.error(ex);
|
||||
}
|
||||
|
||||
// Return the encoded URL string
|
||||
|
||||
return encUrlStr;
|
||||
return encodeURL( urlStr.toString());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -520,6 +507,86 @@ public class WebDAV
|
||||
return strNormalized;
|
||||
}
|
||||
|
||||
/**
|
||||
* Encodes the given URL string
|
||||
*
|
||||
* @param string the String to convert
|
||||
*/
|
||||
public static String encodeURL(String string)
|
||||
{
|
||||
if (string == null)
|
||||
{
|
||||
return "";
|
||||
}
|
||||
|
||||
StringBuilder sb = null; //create on demand
|
||||
String enc;
|
||||
char c;
|
||||
for (int i = 0; i < string.length(); i++)
|
||||
{
|
||||
enc = null;
|
||||
c = string.charAt(i);
|
||||
switch (c)
|
||||
{
|
||||
case '"': enc = """; break; //"
|
||||
case '&': enc = "&"; break; //&
|
||||
case '<': enc = "<"; break; //<
|
||||
case '>': enc = ">"; break; //>
|
||||
|
||||
//german umlauts
|
||||
case '\u00E4' : enc = "ä"; break;
|
||||
case '\u00C4' : enc = "Ä"; break;
|
||||
case '\u00F6' : enc = "ö"; break;
|
||||
case '\u00D6' : enc = "Ö"; break;
|
||||
case '\u00FC' : enc = "ü"; break;
|
||||
case '\u00DC' : enc = "Ü"; break;
|
||||
case '\u00DF' : enc = "ß"; break;
|
||||
|
||||
//misc
|
||||
//case 0x80: enc = "€"; break; sometimes euro symbol is ascii 128, should we suport it?
|
||||
case '\u20AC': enc = "€"; break;
|
||||
case '\u00AB': enc = "«"; break;
|
||||
case '\u00BB': enc = "»"; break;
|
||||
case '\u00A0': enc = " "; break;
|
||||
|
||||
default:
|
||||
if (((int)c) >= 0x80)
|
||||
{
|
||||
//encode all non basic latin characters
|
||||
enc = "&#" + ((int)c) + ";";
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
if (enc != null)
|
||||
{
|
||||
if (sb == null)
|
||||
{
|
||||
String soFar = string.substring(0, i);
|
||||
sb = new StringBuilder(i + 8);
|
||||
sb.append(soFar);
|
||||
}
|
||||
sb.append(enc);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (sb != null)
|
||||
{
|
||||
sb.append(c);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (sb == null)
|
||||
{
|
||||
return string;
|
||||
}
|
||||
else
|
||||
{
|
||||
return sb.toString();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Make a unique lock token
|
||||
*
|
||||
|
Reference in New Issue
Block a user