lynx/lynx-2.9.0dev.10-xhtml.patch
2022-07-07 13:19:20 +02:00

166 lines
5.4 KiB
Diff

From efc075db2309c3dee59b80b6a8488d5f429c0297 Mon Sep 17 00:00:00 2001
From: "Thomas E. Dickey" <dickey@invisible-island.net>
Date: Mon, 13 Jun 2022 00:23:57 +0000
Subject: [PATCH] add presentation type for xhtml
...related state information to better handle things
such as "<script src=foo />" -Sholmi Fish, TD
snapshot of project "lynx", label v2-9-0dev_10h
Upstream-commit: 6308534d913fccf7c0a17d592b9584e15fac455c
Signed-off-by: Kamil Dudka <kdudka@redhat.com>
---
WWW/Library/Implementation/SGML.c | 16 +++++++++++-----
WWW/Library/Implementation/SGML.h | 4 +++-
src/HTInit.c | 2 +-
src/HTML.c | 18 ++++++++++++++----
src/HTML.h | 5 +++++
5 files changed, 34 insertions(+), 11 deletions(-)
diff --git a/WWW/Library/Implementation/SGML.c b/WWW/Library/Implementation/SGML.c
index d120644..e211b2a 100644
--- a/WWW/Library/Implementation/SGML.c
+++ b/WWW/Library/Implementation/SGML.c
@@ -1621,7 +1621,8 @@ static BOOL ignore_when_empty(HTTag * tag)
&& !(tag->flags & Tgf_mafse)
&& tag->contents != SGML_EMPTY
&& tag->tagclass != Tgc_Plike
- && (tag->tagclass == Tgc_SELECTlike
+ && (tag->tagclass == Tgc_APPLETlike
+ || tag->tagclass == Tgc_SELECTlike
|| (tag->contains && tag->icontains))) {
result = TRUE;
}
@@ -3644,9 +3645,9 @@ static void SGML_character(HTStream *me, int c_in)
case S_attr:
if (WHITE(c) || (c == '>') || (c == '=')) { /* End of word */
if ((c == '>')
- && (string->size == 1)
- && (string->data[0] == '/')) {
- if (me->extended_html
+ && (string->size >= 1)
+ && (string->data[string->size - 1] == '/')) {
+ if ((LYxhtml_parsing || me->extended_html)
&& ignore_when_empty(me->current_tag)) {
discard_empty(me);
}
@@ -4590,7 +4591,8 @@ const HTStreamClass SGMLParser =
HTStream *SGML_new(const SGML_dtd * dtd,
HTParentAnchor *anchor,
- HTStructured * target)
+ HTStructured * target,
+ int extended_html)
{
HTStream *me = typecalloc(struct _HTStream);
@@ -4660,6 +4662,10 @@ HTStream *SGML_new(const SGML_dtd * dtd,
sgml_in_psrc_was_initialized = TRUE;
}
#endif
+ if (extended_html)
+ {
+ me->extended_html = TRUE;
+ }
sgml_offset = 0;
return me;
diff --git a/WWW/Library/Implementation/SGML.h b/WWW/Library/Implementation/SGML.h
index 8b6445f..2ddef5f 100644
--- a/WWW/Library/Implementation/SGML.h
+++ b/WWW/Library/Implementation/SGML.h
@@ -281,7 +281,9 @@ Create an SGML parser
*/
extern HTStream *SGML_new(const SGML_dtd * dtd,
HTParentAnchor *anchor,
- HTStructured * target);
+ HTStructured * target,
+ int extended_html)
+ ;
extern const HTStreamClass SGMLParser;
diff --git a/src/HTInit.c b/src/HTInit.c
index c451762..bd41dee 100644
--- a/src/HTInit.c
+++ b/src/HTInit.c
@@ -178,7 +178,7 @@ void HTFormatInit(void)
* application/xhtml+xml
* text/html
*/
- SET_INTERNL("application/xhtml+xml", "www/present", HTMLPresent, 1.0);
+ SET_INTERNL("application/xhtml+xml", "www/present", XHTMLPresent, 1.0);
SET_INTERNL("application/xhtml+xml", "www/source", HTPlainPresent, 1.0);
SET_INTERNL("text/css", "www/present", HTPlainPresent, 1.0);
SET_INTERNL(STR_HTML, "www/present", HTMLPresent, 1.0);
diff --git a/src/HTML.c b/src/HTML.c
index a012466..9ec15c2 100644
--- a/src/HTML.c
+++ b/src/HTML.c
@@ -7957,7 +7957,7 @@ HTStream *HTMLToPlain(HTPresentation *pres,
CTRACE((tfp, "HTMLToPlain calling CacheThru_new\n"));
return CacheThru_new(anchor,
SGML_new(&HTML_dtd, anchor,
- HTML_new(anchor, pres->rep_out, sink)));
+ HTML_new(anchor, pres->rep_out, sink), FALSE));
}
/* HTConverter for HTML source to plain text
@@ -8020,7 +8020,7 @@ HTStream *HTMLParsedPresent(HTPresentation *pres,
CTRACE((tfp, "HTMLParsedPresent calling CacheThru_new\n"));
return CacheThru_new(anchor,
SGML_new(&HTML_dtd, anchor,
- HTMLGenerator(intermediate)));
+ HTMLGenerator(intermediate), FALSE));
}
/* HTConverter for HTML to C code
@@ -8048,7 +8048,7 @@ HTStream *HTMLToC(HTPresentation *pres GCC_UNUSED,
HTML_put_string(html, html->comment_start);
CTRACE((tfp, "HTMLToC calling CacheThru_new\n"));
return CacheThru_new(anchor,
- SGML_new(&HTML_dtd, anchor, html));
+ SGML_new(&HTML_dtd, anchor, html, FALSE));
}
/* Presenter for HTML
@@ -8067,7 +8067,17 @@ HTStream *HTMLPresent(HTPresentation *pres GCC_UNUSED,
CTRACE((tfp, "HTMLPresent calling CacheThru_new\n"));
return CacheThru_new(anchor,
SGML_new(&HTML_dtd, anchor,
- HTML_new(anchor, WWW_PRESENT, NULL)));
+ HTML_new(anchor, WWW_PRESENT, NULL), FALSE));
+}
+
+HTStream *XHTMLPresent(HTPresentation *pres GCC_UNUSED,
+ HTParentAnchor *anchor,
+ HTStream *sink GCC_UNUSED)
+{
+ CTRACE((tfp, "XHTMLPresent calling CacheThru_new\n"));
+ return CacheThru_new(anchor,
+ SGML_new(&HTML_dtd, anchor,
+ HTML_new(anchor, WWW_PRESENT, NULL), TRUE));
}
#endif /* !GUI */
diff --git a/src/HTML.h b/src/HTML.h
index 9f5d1d5..0baa23e 100644
--- a/src/HTML.h
+++ b/src/HTML.h
@@ -251,6 +251,11 @@ extern "C" {
HTParentAnchor *anchor,
HTStream *sink);
+ extern HTStream *XHTMLPresent(HTPresentation *pres,
+ HTParentAnchor *anchor,
+ HTStream *sink);
+
+
extern HTStructured *HTML_new(HTParentAnchor *anchor,
HTFormat format_out,
HTStream *target);
--
2.35.3