mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
Don't urlencode "serverUrl" template variable in GenericRepository fields
This commit is contained in:
@@ -16,6 +16,7 @@ import org.apache.commons.httpclient.Header;
|
||||
import org.apache.commons.httpclient.HttpMethod;
|
||||
import org.apache.commons.httpclient.HttpStatus;
|
||||
import org.apache.commons.httpclient.methods.GetMethod;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
@@ -33,21 +34,25 @@ import static com.intellij.tasks.generic.TemplateVariable.*;
|
||||
public class GenericRepository extends BaseRepositoryImpl {
|
||||
private static final Logger LOG = Logger.getInstance(GenericRepository.class);
|
||||
|
||||
public final FactoryVariable SERVER_URL_TEMPLATE_VARIABLE = new FactoryVariable("serverUrl") {
|
||||
@NonNls public static final String SERVER_URL = "serverUrl";
|
||||
@NonNls public static final String USERNAME = "username";
|
||||
@NonNls public static final String PASSWORD = "password";
|
||||
|
||||
public final FactoryVariable SERVER_URL_TEMPLATE_VARIABLE = new FactoryVariable(SERVER_URL) {
|
||||
@NotNull
|
||||
@Override
|
||||
public String getValue() {
|
||||
return GenericRepository.this.getUrl();
|
||||
}
|
||||
};
|
||||
public final FactoryVariable USERNAME_TEMPLATE_VARIABLE = new FactoryVariable("username") {
|
||||
public final FactoryVariable USERNAME_TEMPLATE_VARIABLE = new FactoryVariable(USERNAME) {
|
||||
@NotNull
|
||||
@Override
|
||||
public String getValue() {
|
||||
return GenericRepository.this.getUsername();
|
||||
}
|
||||
};
|
||||
public final FactoryVariable PASSWORD_TEMPLATE_VARIABLE = new FactoryVariable("password", true) {
|
||||
public final FactoryVariable PASSWORD_TEMPLATE_VARIABLE = new FactoryVariable(PASSWORD, true) {
|
||||
@NotNull
|
||||
@Override
|
||||
public String getValue() {
|
||||
|
||||
@@ -56,9 +56,15 @@ public class GenericRepositoryUtil {
|
||||
String name = m.group(1);
|
||||
String replacement = lookup.get(name);
|
||||
if (replacement == null) {
|
||||
throw new Exception((String.format("Template variable '%s' is not defined", name)));
|
||||
throw new Exception((String.format("Template variable '%s' is undefined", name)));
|
||||
}
|
||||
// TODO: add proper escape|unescape property to template variables
|
||||
if (escape && !name.equals(GenericRepository.SERVER_URL)) {
|
||||
m.appendReplacement(sb, URLEncoder.encode(replacement, "utf-8"));
|
||||
}
|
||||
else {
|
||||
m.appendReplacement(sb, replacement);
|
||||
}
|
||||
m.appendReplacement(sb, escape? URLEncoder.encode(replacement, "utf-8") : replacement);
|
||||
}
|
||||
return m.appendTail(sb).toString();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user