use of com.google.common.escape.Escaper in project core-java by SpineEventEngine.
the class Stringifiers method createEscaper.
/**
* Creates the {@code Escaper} which escapes contained '\' and passed characters.
*
* @param charToEscape the char to escape
* @return the constructed escaper
*/
static Escaper createEscaper(char charToEscape) {
final String escapedChar = "\\" + charToEscape;
final Escaper result = Escapers.builder().addEscape('\"', "\\\"").addEscape(charToEscape, escapedChar).build();
return result;
}
use of com.google.common.escape.Escaper in project AuthMeReloaded by AuthMe.
the class TwoFactor method getQRBarcodeURL.
public static String getQRBarcodeURL(String user, String host, String secret) {
String format = "https://www.google.com/chart?chs=130x130&chld=M%%7C0&cht=qr&chl=" + "otpauth://totp/" + "%s@%s%%3Fsecret%%3D%s";
Escaper urlEscaper = UrlEscapers.urlFragmentEscaper();
return String.format(format, urlEscaper.escape(user), urlEscaper.escape(host), secret);
}
use of com.google.common.escape.Escaper in project android by JetBrains.
the class SubmitFeedback method actionPerformed.
@Override
public void actionPerformed(AnActionEvent e) {
Project project = e.getProject();
if (project == null) {
Logger.getInstance(SubmitFeedback.class).info("Unable to identify current project");
return;
}
if (!InstantRunSettings.isInstantRunEnabled() || !InstantRunSettings.isRecorderEnabled()) {
int result = Messages.showYesNoDialog(project, AndroidBundle.message("instant.run.flr.would.you.like.to.enable"), AndroidBundle.message("instant.run.flr.dialog.title"), "Yes, I'd like to help", "Cancel", Messages.getQuestionIcon());
if (result == Messages.NO) {
return;
}
InstantRunSettings.setInstantRunEnabled(true);
InstantRunSettings.setRecorderEnabled(true);
Messages.showInfoMessage(project, AndroidBundle.message("instant.run.flr.howto"), AndroidBundle.message("instant.run.flr.dialog.title"));
return;
}
InstantRunFeedbackDialog dialog = new InstantRunFeedbackDialog(project);
boolean ok = dialog.showAndGet();
if (ok) {
new Task.Backgroundable(project, "Submitting Instant Run Issue") {
public CompletableFuture<String> myReport;
@Override
public void run(@NotNull ProgressIndicator indicator) {
myReport = GoogleCrash.getInstance().submit(FlightRecorder.get(project), dialog.getIssueText(), dialog.getLogs());
while (!myReport.isDone()) {
try {
myReport.get(200, TimeUnit.MILLISECONDS);
} catch (Exception ignored) {
}
if (indicator.isCanceled()) {
return;
}
}
}
@Override
public void onSuccess() {
if (myReport.isDone()) {
String reportId;
try {
reportId = myReport.getNow("00");
} catch (CancellationException e) {
Logger.getInstance(SubmitFeedback.class).info("Submission of flight recorder logs cancelled");
return;
} catch (CompletionException e) {
FLR_NOTIFICATION_GROUP.createNotification("Unexpected error while submitting instant run logs: " + e.getMessage(), NotificationType.ERROR);
Logger.getInstance(SubmitFeedback.class).info(e);
return;
}
String message = String.format("<html>Thank you for submitting the bug report.<br>" + "If you would like to follow up on this report, please file a bug at <a href=\"bug\">b.android.com</a> and specify the report id '%1$s'<html>", reportId);
FLR_NOTIFICATION_GROUP.createNotification("", message, NotificationType.INFORMATION, (notification, event) -> {
Escaper escaper = UrlEscapers.urlFormParameterEscaper();
String comment = String.format("Build: %1$s\nInstant Run Report: %2$s", ApplicationInfo.getInstance().getFullVersion(), reportId);
String url = String.format("https://code.google.com/p/android/issues/entry?template=%1$s&comment=%2$s&status=New", escaper.escape("Android Studio Instant Run Bug"), escaper.escape(comment));
BrowserUtil.browse(url);
}).notify(project);
}
}
}.queue();
}
}
use of com.google.common.escape.Escaper in project spf4j by zolyfarkas.
the class Method method toHtmlWriter.
public void toHtmlWriter(final Writer w) throws IOException {
Escaper htmlEscaper = HtmlEscapers.htmlEscaper();
w.append(htmlEscaper.escape(methodName)).append(htmlEscaper.escape("@")).append(htmlEscaper.escape(declaringClass));
}
use of com.google.common.escape.Escaper in project mylyn.docs by eclipse.
the class PotentialBracketEndDelimiter method normalizeUri.
private String normalizeUri(String uriWithEscapes) {
String uriWithoutBackslashEscapes = unescapeBackslashEscapes(uriWithEscapes);
try {
String uriWithoutHtmlEntities = replaceHtmlEntities(uriWithoutBackslashEscapes, UrlEscapers.urlFormParameterEscaper());
String decoded = URLDecoder.decode(uriWithoutHtmlEntities, StandardCharsets.UTF_8.name());
Escaper escaper = UrlEscapers.urlFragmentEscaper();
int indexOfHash = decoded.indexOf('#');
if (indexOfHash != -1) {
String uri = escaper.escape(decoded.substring(0, indexOfHash)) + '#';
if ((indexOfHash + 1) < decoded.length()) {
uri += escaper.escape(decoded.substring(indexOfHash + 1));
}
return uri;
}
return escaper.escape(decoded);
} catch (Exception e) {
return uriWithoutBackslashEscapes;
}
}
Aggregations