mirror of
https://git.imnavajas.es/jjimenez/erp-imprimelibros.git
synced 2026-01-13 08:58:48 +00:00
falta borrar y busqueda por columnas
This commit is contained in:
25
src/main/java/com/imprimelibros/erp/config/Sanitizer.java
Normal file
25
src/main/java/com/imprimelibros/erp/config/Sanitizer.java
Normal file
@ -0,0 +1,25 @@
|
||||
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);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user