0

jsoup を使用して、ユーザーが入力した html コードをクリーンアップしています (通常、ユーザーはタグを閉じるのを忘れていました)。新しいエントリに対しては非常にうまく機能しますが、以前のエントリを編集するときは何もしません (すでに jsoup によって消去されています)。コードは次のとおりです。

public void on_newMyData(Dictionary d, Attributes a, Transaction t) throws LogicException {
  sanitizeHTMLInput(d,a,t);
}
public void on_editMyData(Dictionary d, Attributes a, Transaction t) throws LogicException {
  sanitizeHTMLInput(d,a,t);
}
private void sanitizeHTMLInput(Dictionary d, Attributes a, Transaction t) throws LogicException {
  try {
    Object unsafe = a.getAttribute("answer");
    String safe = Jsoup.clean(String.valueOf(unsafe), Whitelist.relaxed());
    d.put("answer",safe);       
  } catch (AttributeNotFoundException e) {
    //if the answer is empty, no sanitizing is needed
  }
}

私は何か間違ったことをしていますか、それとも私が見つけられなかった制限がありますか?

4

0 に答える 0