Search in sources :

Example 1 with Escaper

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;
}
Also used : Escaper(com.google.common.escape.Escaper)

Example 2 with Escaper

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);
}
Also used : Escaper(com.google.common.escape.Escaper)

Example 3 with Escaper

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();
    }
}
Also used : Task(com.intellij.openapi.progress.Task) CancellationException(java.util.concurrent.CancellationException) CompletionException(java.util.concurrent.CompletionException) Project(com.intellij.openapi.project.Project) CancellationException(java.util.concurrent.CancellationException) ProgressIndicator(com.intellij.openapi.progress.ProgressIndicator) CompletionException(java.util.concurrent.CompletionException) Escaper(com.google.common.escape.Escaper)

Example 4 with Escaper

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));
}
Also used : Escaper(com.google.common.escape.Escaper)

Example 5 with Escaper

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;
    }
}
Also used : Escaper(com.google.common.escape.Escaper)

Aggregations

Escaper (com.google.common.escape.Escaper)17 Map (java.util.Map)2 TextMatching (annis.model.QueryNode.TextMatching)1 IndentedLinesBuilder (com.google.template.soy.base.internal.IndentedLinesBuilder)1 SoyMsg (com.google.template.soy.msgs.restricted.SoyMsg)1 SoyMsgPart (com.google.template.soy.msgs.restricted.SoyMsgPart)1 SoyMsgPlaceholderPart (com.google.template.soy.msgs.restricted.SoyMsgPlaceholderPart)1 SoyMsgRawTextPart (com.google.template.soy.msgs.restricted.SoyMsgRawTextPart)1 ProgressIndicator (com.intellij.openapi.progress.ProgressIndicator)1 Task (com.intellij.openapi.progress.Task)1 Project (com.intellij.openapi.project.Project)1 CharacterEscapeHandler (com.sun.xml.bind.marshaller.CharacterEscapeHandler)1 IOException (java.io.IOException)1 Writer (java.io.Writer)1 CancellationException (java.util.concurrent.CancellationException)1 CompletionException (java.util.concurrent.CompletionException)1 JAXBContext (javax.xml.bind.JAXBContext)1 JAXBException (javax.xml.bind.JAXBException)1 Marshaller (javax.xml.bind.Marshaller)1 Test (org.junit.Test)1