org.apache.commons.lang3.StringEscapeUtils#unescapeHtml4 ( )源码实例Demo

下面列出了org.apache.commons.lang3.StringEscapeUtils#unescapeHtml4 ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: zest-writer   文件: MdTextController.java
@FXML
private void handleValidateButtonAction(ActionEvent event) {
    String s = StringEscapeUtils.unescapeHtml4(markdownToHtml(currentSourceText.getText()));
    if (MdConvertController.corrector == null) {
        MdConvertController.corrector = new Corrector();
    }
    try {
        String result = MdConvertController.corrector.checkHtmlContent(s);
        WebEngine webEngine = currentRenderView.getEngine();
        webEngine.loadContent("<!doctype html><html lang='fr'><head><meta charset='utf-8'><base href='"
                + MainApp.class.getResource("assets").toExternalForm() + "' /></head><body>" + result + "</body></html>");
        webEngine.setUserStyleSheetLocation(MainApp.class.getResource("assets/static/css/content.css").toExternalForm());
    } catch (DOMException e) {
        log.error(e.getMessage(), e);
    }
}
 
源代码2 项目: zest-writer   文件: CorrectionService.java
@Override
protected Task<String> createTask() {
    return new Task<String>() {
        @Override
        protected String call(){
            updateMessage(Configuration.getBundle().getString("ui.task.correction.prepare.label")+" ...");

            Function<Textual, String> prepareValidationReport = (Textual ext) -> {
                updateMessage(ext.getTitle());
                String markdown = ext.readMarkdown();
                if(!mdText.isPythonStarted()) {
                    MainApp.getLogger().debug("Jython en cours de chargement mémoire");
                    return null;
                } else {
                    String htmlText = StringEscapeUtils.unescapeHtml4(MenuController.markdownToHtml(mdText, markdown));
                    return corrector.checkHtmlContentToText(htmlText, ext.getTitle());
                }
            };
            Map<Textual, String> validationResult = content.doOnTextual(prepareValidationReport);

            StringBuilder resultCorrect = new StringBuilder();
            for (Entry<Textual, String> entry : validationResult.entrySet()) {
                resultCorrect.append(entry.getValue());
            }
            return StringEscapeUtils.unescapeHtml4(resultCorrect.toString());
        }
    };
}
 
源代码3 项目: ache   文件: PaginaURL.java
protected String addLink(String link, HttpUrl base) {
    if (nofollow) {
        return "";
    }
    link = link.trim();
    link = Urls.resolveHttpLink(base, link);
    if (link == null) {
        return "";
    }
    link = Urls.removeFragmentsIfAny(link);
    link = StringEscapeUtils.unescapeHtml4(link);
    if (Urls.isValid(link)) {
        link = Urls.normalize(link);
        if (link != null) {
            boolean exists = links.contains(link);
            if (!exists) {
                if (base != null && !link.equals(base.toString())) {
                    links.add(link);
                } else {
                    links.add(link);
                }
            }
        }
    } else {
        // link is invalid
        link = null;
    }
    return link;
}
 
源代码4 项目: LibreNews-Android   文件: FlashManager.java
public void pushFlashNotification(Flash flash) throws JSONException, IOException {
    if (!prefs.getBoolean("notifications_enabled", true)) {
        return;
    }
    Intent notificationIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(flash.getLink()));
    PendingIntent pendingIntent = PendingIntent.getActivity(context, 0, notificationIntent, 0);
    String text = StringEscapeUtils.unescapeHtml4(flash.getText());
    NotificationManager mNotificationManager =
            (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
    if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.O){
        Notification.Builder oBuilder = new Notification.Builder(context, getNotificationChannel(context).getId());
        oBuilder.setContentTitle(flash.getChannel() + " • " + flash.getSource())
                .setStyle(new Notification.BigTextStyle()
                        .bigText(text))
                .setContentText(text)
                .setAutoCancel(true)
                .setSound(Uri.parse(prefs.getString("notification_sound", "DEFAULT")))
                .setContentIntent(pendingIntent)
                .setSmallIcon(R.drawable.ic_alert);
        mNotificationManager.notify(flash.getIdAsInteger(), oBuilder.build());
    }else{
        NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(context)
                .setContentTitle(flash.getChannel() + " • " + flash.getSource())
                .setStyle(new NotificationCompat.BigTextStyle()
                        .bigText(text))
                .setContentText(text)
                .setAutoCancel(true)
                .setSound(Uri.parse(prefs.getString("notification_sound", "DEFAULT")))
                .setContentIntent(pendingIntent);
        if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
            mBuilder.setSmallIcon(R.drawable.ic_alert);
        } else {
            mBuilder.setSmallIcon(R.drawable.ic_alert_compat);
        }
        mNotificationManager.notify(flash.getIdAsInteger(), mBuilder.build());
    }
}
 
源代码5 项目: zest-writer   文件: Content.java
public void saveToHtml(File file, MdTextController index) {
    try (FileOutputStream fos = new FileOutputStream(file)) {
        BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(fos, "UTF8"));
        String mdValue = exportContentToMarkdown(0, getDepth());
        String htmlValue = StringEscapeUtils.unescapeHtml4(index.markdownToHtml(mdValue));
        htmlValue = normalizeHtml(htmlValue);
        writer.append(MainApp.getMdUtils().addHeaderAndFooterStrict(htmlValue, getTitle()));
        writer.flush();
    } catch (Exception e) {
        MainApp.getLogger().error(e.getMessage(), e);
    }
}
 
源代码6 项目: Overchan-Android   文件: AbstractVichanModule.java
private void handleFilter(int i) throws IOException {
    switch (i) {
        case FILTER_INPUT_OPEN:
            currentReading = true;
            currentTextarea = false;
            break;
        case FILTER_TEXTAREA_OPEN:
            currentReading = true;
            currentTextarea = true;
            break;
        case FILTER_NAME_OPEN:
            currentName = StringEscapeUtils.unescapeHtml4(readUntilSequence("\"".toCharArray()));
            break;
        case FILTER_VALUE_OPEN:
            currentValue = StringEscapeUtils.unescapeHtml4(readUntilSequence("\"".toCharArray()));
            break;
        case FILTER_TAG_CLOSE:
            if (currentTextarea) {
                currentValue = StringEscapeUtils.unescapeHtml4(readUntilSequence("<".toCharArray()));
            }
            if (currentReading && currentName != null) result.add(Pair.of(currentName, currentValue != null ? currentValue : ""));
            currentName = null;
            currentValue = null;
            currentReading = false;
            currentTextarea = false;
            break;
        case FILTER_TAG_BEFORE_CLOSE: // <textarea ..... />
            currentTextarea = false;
            break;
    }
}
 
源代码7 项目: Overchan-Android   文件: Chan410Reader.java
@Override
protected void parseDate(String date) {
    super.parseDate(date);
    if (currentPost.timestamp == 0) {
        Matcher matcher = SPAN_ADMIN_PATTERN.matcher(date);
        if (matcher.matches()) {
            currentPost.trip = (currentPost.trip == null ? "" : currentPost.trip) + StringEscapeUtils.unescapeHtml4(matcher.group(1).trim());
            super.parseDate(matcher.group(2));
        }
    }
}
 
源代码8 项目: aurous-app   文件: SoundCloudService.java
/**
 * @author Andrew Returns the title of the Soundcloud url provided
 *
 * @return title
 */
private static String getSongTitle(final String HTML) {
	String title = "";

	title = MediaUtils.getBetween(HTML, TITLE_PATTERN, "\",\"");
	title = StringEscapeUtils.escapeHtml4(title.replaceAll(
			"[^\\x20-\\x7e]", ""));
	title = Utils.convertUnicode(title);
	title = StringEscapeUtils.unescapeHtml4(title);

	if (title.contains(",")) {
		title = escapeComma(title);
	}
	return title.trim();
}
 
源代码9 项目: TagRec   文件: Utilities.java
public static String getWikiContent(String xmlString) {
    int startIndex = xmlString.indexOf(REV_START);
    int endIndex = xmlString.indexOf(REV_END);
    if (startIndex != -1 && endIndex != -1) {
        return StringEscapeUtils.unescapeHtml4(xmlString.substring(startIndex + REV_START.length(), endIndex));
    }
    return null;
}
 
源代码10 项目: esigate   文件: UrlRewriter.java
private String unescapeHtml(String url) {
    // Unescape entities, ex: &apos; or &#39;
    url = StringEscapeUtils.unescapeHtml4(url);
    return url;
}
 
源代码11 项目: jee-universal-bms   文件: Encodes.java
/**
 * Html 解码.
 */
public static String unescapeHtml(String htmlEscaped) {
	return StringEscapeUtils.unescapeHtml4(htmlEscaped);
}
 
源代码12 项目: Overchan-Android   文件: Subscriptions.java
private static String htmlToComment(String html) {
    return StringEscapeUtils.unescapeHtml4(RegexUtils.removeHtmlTags(html.replaceAll("<(br|p)/?>", " ")));
}
 
源代码13 项目: MultimediaDesktop   文件: Encodes.java
/**
 * Html 解码.
 */
public static String unescapeHtml(String htmlEscaped) {
	return StringEscapeUtils.unescapeHtml4(htmlEscaped);
}
 
源代码14 项目: shopify-sdk   文件: ShopifyVariantUpdateRequest.java
private boolean doesNotEqual(final String s1, final String s2) {
	final String unescapedS1 = StringEscapeUtils.unescapeHtml4(StringUtils.trim(s1));
	final String unescapedS2 = StringEscapeUtils.unescapeHtml4(StringUtils.trim(s2));
	return !StringUtils.equals(unescapedS1, unescapedS2);
}
 
源代码15 项目: spring-boot-quickstart   文件: Encodes.java
/**
 * Html 解码.
 */
public static String unescapeHtml(String htmlEscaped) {
	return StringEscapeUtils.unescapeHtml4(htmlEscaped);
}
 
源代码16 项目: rtc2jira   文件: DescriptionMapping.java
public static String convertHtmlToJiraMarkup(String text) {
  String rnProxy = "caburacelhota";
  String rn = "\r\n";

  if (text != null) {
    // line breaks
    text = text.replaceAll("<br/>", rnProxy);
    // bold
    text = text.replaceAll("<b>", "*");
    text = text.replaceAll("</b>", "*");
    // italics
    text = text.replaceAll("<i>", "_");
    text = text.replaceAll("</i>", "_");
    // emphasis
    text = text.replaceAll("<em>", "_");
    text = text.replaceAll("</em>", "_");
    // deleted
    text = text.replaceAll("<del>", "-");
    text = text.replaceAll("</del>", "-");
    // inserted
    text = text.replaceAll("<ins>", "+");
    text = text.replaceAll("</ins>", "+");
    // superscript
    text = text.replaceAll("<sup>", "^");
    text = text.replaceAll("</sup>", "^");
    // subscript
    text = text.replaceAll("<sub>", "~");
    text = text.replaceAll("</sub>", "~");

    text = replaceHtmlAnchors(text, true);

    // delete remaining html tags (open-close)
    text = text.replaceAll("\\<.*?>", " ").replaceAll("\\s+", " ").trim();

    // entities
    text = StringEscapeUtils.unescapeHtml4(text);

    text = text.replaceAll(rnProxy, rn);
  }

  return text;
}
 
源代码17 项目: dubai   文件: Encodes.java
/**
 * Html 解码.
 */
public static String unescapeHtml(String htmlEscaped) {
	return StringEscapeUtils.unescapeHtml4(htmlEscaped);
}
 
源代码18 项目: pega-tracerviewer   文件: TraceEvent.java
public boolean search(Object searchStrObj) {

        boolean found = false;

        if (searchStrObj instanceof SearchEventType) {

            SearchEventType searchEventType = (SearchEventType) searchStrObj;

            switch (searchEventType) {

            case PAGE_MESSAGES:
                found = isHasMessages();
                break;

            case STATUS_WARN:
                found = isStepStatusWarn();
                break;

            case STATUS_FAIL:
                found = isStepStatusFail();
                break;

            case STATUS_EXCEPTION:
                found = isStepStatusException();
                break;

            case SEPERATOR:
                break;
            default:
                break;
            }
        } else {

            String traceEventStr = getTraceEventStr();
            String searchStr = (String) searchStrObj;

            // traceEventStr will null in case of empty or corrupt TE's
            if ((traceEventStr != null) && (searchStr != null)) {

                traceEventStr = traceEventStr.toLowerCase();
                String traceSearchStr = searchStr.toLowerCase();

                byte[] pattern = traceSearchStr.getBytes();
                byte[] data = traceEventStr.getBytes();

                int index = KnuthMorrisPrattAlgorithm.indexOf(data, pattern);

                if (index != -1) {
                    found = true;
                }

                // double searching - because some data is escaped. but user can use escaped or
                // unescaped text for search.
                if (!found) {

                    // if the unescaped string is same as orig, then dont do second search
                    String unescTraceEventStr = StringEscapeUtils.unescapeHtml4(traceEventStr);

                    if (!unescTraceEventStr.equals(traceEventStr)) {
                        data = unescTraceEventStr.getBytes();

                        index = KnuthMorrisPrattAlgorithm.indexOf(data, pattern);

                        if (index != -1) {
                            found = true;
                        }
                    }
                }
            }
        }

        searchFound = found;

        return found;
    }
 
源代码19 项目: easyweb   文件: Encodes.java
/**
 * Html 解码.
 */
public static String unescapeHtml(String htmlEscaped) {
	return StringEscapeUtils.unescapeHtml4(htmlEscaped);
}
 
源代码20 项目: vjtools   文件: EscapeUtil.java
/**
 * Html解码,将HTML4格式的字符串转码解码为普通字符串.
 * 
 * 比如 &quot;bread&quot; &amp; &quot;butter&quot;转化为"bread" & "butter"
 */
public static String unescapeHtml(String html) {
	return StringEscapeUtils.unescapeHtml4(html);
}