mirror of
https://git.imnavajas.es/jjimenez/erp-imprimelibros.git
synced 2026-01-13 08:58:48 +00:00
26 lines
732 B
Java
26 lines
732 B
Java
package com.imprimelibros.erp.config;
|
|
|
|
import org.jsoup.Jsoup;
|
|
import org.jsoup.safety.Safelist;
|
|
import org.springframework.stereotype.Component;
|
|
|
|
@Component
|
|
public class Sanitizer {
|
|
|
|
// Sin HTML: todo a texto plano
|
|
public String plain(String input) {
|
|
if (input == null) return null;
|
|
String cleaned = Jsoup.clean(input, Safelist.none());
|
|
return cleaned.strip();
|
|
}
|
|
|
|
// HTML mínimo permitido (opcional)
|
|
public String minimalHtml(String input) {
|
|
if (input == null) return null;
|
|
Safelist wl = Safelist.basic(); // b, i, em, strong, a...
|
|
wl.addTags("ul","ol","li"); // añade lo que necesites
|
|
wl.addAttributes("a","rel","nofollow"); // endurece enlaces
|
|
return Jsoup.clean(input, wl);
|
|
}
|
|
}
|