[PATCH] removing nodes from a dom
folkert <[email protected]> Sun, 12 Jul 2015 14:36:58 +0200
| Newsgroups | gmane.comp.web.html-tidy.devel |
|---|---|
| Organization | www.smartwinning.info |
| Message-ID | <[email protected]> |
Hi,
Here's a patch for (lib-)tidy which allows developers to remove a node
from a dom.
I added this function so that I can use (lib-)tidy in a piece of code
which removes dangerous html (dangerous for my use-case). For example
scripting, iframes, etc.
Please consider including it. Thanks.
diff -uNrBbd tidy/include/tidy.h tidy-new/include/tidy.h
--- tidy/include/tidy.h 2008-04-22 11:00:42.000000000 +0000
+++ tidy-new/include/tidy.h 2015-07-12 11:59:11.251382612 +0000
@@ -801,6 +801,9 @@
TIDY_EXPORT TidyNode TIDY_CALL tidyGetHead( TidyDoc tdoc );
TIDY_EXPORT TidyNode TIDY_CALL tidyGetBody( TidyDoc tdoc );
=
+/* remove a node */
+TIDY_EXPORT TidyNode TIDY_CALL tidyDiscardElement( TidyDoc tdoc, TidyNo=
de tnod );
+
/* parent / child */
TIDY_EXPORT TidyNode TIDY_CALL tidyGetParent( TidyNode tnod );
TIDY_EXPORT TidyNode TIDY_CALL tidyGetChild( TidyNode tnod );
diff -uNrBbd tidy/src/tidylib.c tidy-new/src/tidylib.c
--- tidy/src/tidylib.c 2008-06-18 20:18:54.000000000 +0000
+++ tidy-new/src/tidylib.c 2015-07-12 11:55:04.745221204 +0000
@@ -1499,6 +1499,15 @@
return tidyImplToNode( nimp->content );
}
=
+/* remove a node */
+TidyNode TIDY_CALL tidyDiscardElement( TidyDoc tdoc, TidyNode tnod )
+{
+ TidyDocImpl* doc =3D tidyDocToImpl( tdoc );
+ Node* nimp =3D tidyNodeToImpl( tnod );
+ Node* next =3D TY_(DiscardElement)( doc, nimp );
+ return tidyImplToNode( next );
+}
+
/* siblings */
TidyNode TIDY_CALL tidyGetNext( TidyNode tnod )
{
Folkert van Heusden
-- =
MultiTail er et flexible tool for =E5 kontrolere Logfiles og commandoer.
Med filtrer, farger, sammenf=F8ringer, forskeliger ansikter etc.
http://www.vanheusden.com/multitail/
----------------------------------------------------------------------
Phone: +31-6-41278122, PGP-key: 1F28D8AE, www.vanheusden.com
---------------------------------------------------------------------------=
---
Don't Limit Your Business. Reach for the Cloud.
GigeNET's Cloud Solutions provide you with the tools and support that
you need to offload your IT needs and focus on growing your business.
Configured For All Businesses. Start Your Cloud Today.
https://www.gigenetcloud.com/