Skip to content

Commit

Permalink
fixed JakduK#357
Browse files Browse the repository at this point in the history
html태그 삭제 방식 교체 jsoup -> regex
텔레그램 초대 링크 삭제
  • Loading branch information
silverprize committed Oct 19, 2019
1 parent 803d0e6 commit 0e1c96f
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 11 deletions.
2 changes: 0 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
[![Telegram](https://img.shields.io/badge/join-telegram-blue.svg)](https://t.me/joinchat/EEdSAQ6kK0zyY_N_6TdW_Q)

jakduk-api
===================
K League Community Web Application.
Expand Down
24 changes: 15 additions & 9 deletions src/main/java/com/jakduk/api/common/util/JakdukUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,27 @@
import com.jakduk.api.model.embedded.CommonFeelingUser;
import com.jakduk.api.model.embedded.CommonWriter;
import com.jakduk.api.model.embedded.LocalName;

import org.apache.commons.lang3.StringUtils;
import org.apache.commons.text.RandomStringGenerator;
import org.jsoup.Jsoup;
import org.springframework.context.i18n.LocaleContextHolder;
import org.springframework.util.CollectionUtils;
import org.springframework.util.ObjectUtils;

import java.text.MessageFormat;
import java.util.ArrayList;
import java.util.List;
import java.util.Locale;
import java.util.Objects;
import java.util.Optional;
import java.util.ResourceBundle;
import java.util.regex.Pattern;
import java.util.stream.Stream;

import javax.servlet.http.Cookie;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import java.text.MessageFormat;
import java.util.*;
import java.util.stream.Stream;

/**
* @author pyohwan
Expand All @@ -27,6 +34,8 @@

public class JakdukUtils {

private static Pattern PATTERN_WITHOUT_TAGS = Pattern.compile("</?(.+?)>");

private final static String GALLERIES_FOR_REMOVAL = ":galleries_for_removal";

private static RandomStringGenerator generator = new RandomStringGenerator.Builder()
Expand Down Expand Up @@ -98,11 +107,8 @@ public static String getValidationMessage(String getString, Object... params) {
/**
* HTML TAG를 제거한다.
*/
public static String stripHtmlTag(String htmlTag) {
String content = StringUtils.defaultIfBlank(htmlTag, StringUtils.EMPTY);
content = Jsoup.parse(content).text();

return content;
public static String stripHtmlTag(String html) {
return PATTERN_WITHOUT_TAGS.matcher(html).replaceAll("");
}

/**
Expand Down

0 comments on commit 0e1c96f

Please sign in to comment.