Introduction
Introduction Statistics Contact Development Disclaimer Help
only escape quotes in attributes, in HTML text nodes it's not needed and ugly -…
git clone git://git.codemadness.org/smu
Log
Files
Refs
README
LICENSE
---
commit b4bfba10cb2c000c39249228fcf6286831484a66
parent 4aea24b36933f3bb3e68fc56226da50803e4d337
Author: Hiltjo Posthuma <[email protected]>
Date: Tue, 11 May 2021 01:42:25 +0200
only escape quotes in attributes, in HTML text nodes it's not needed and ugly
Diffstat:
M smu.c | 31 ++++++++++++++++++++++++-----…
1 file changed, 24 insertions(+), 7 deletions(-)
---
diff --git a/smu.c b/smu.c
@@ -33,6 +33,7 @@ static int dosurround(const char *begin, const char *end, int…
static int dounderline(const char *begin, const char *end, int newblock); /* P…
static void *ereallocz(void *p, size_t size);
static void hprint(const char *begin, const char *end); /* e…
+static void hprintattr(const char *begin, const char *end); …
static void process(const char *begin, const char *end, int isblock); /* P…
/* list of parsers */
@@ -305,24 +306,24 @@ dolink(const char *begin, const char *end, int newblock) {
len = q + 1 - begin;
if(img) {
fputs("<img src=\"", stdout);
- hprint(link, linkend);
+ hprintattr(link, linkend);
fputs("\" alt=\"", stdout);
- hprint(desc, descend);
+ hprintattr(desc, descend);
fputs("\" ", stdout);
if(title && titleend) {
fputs("title=\"", stdout);
- hprint(title, titleend);
+ hprintattr(title, titleend);
fputs("\" ", stdout);
}
fputs("/>", stdout);
}
else {
fputs("<a href=\"", stdout);
- hprint(link, linkend);
+ hprintattr(link, linkend);
fputs("\"", stdout);
if(title && titleend) {
fputs(" title=\"", stdout);
- hprint(title, titleend);
+ hprintattr(title, titleend);
fputs("\"", stdout);
}
fputs(">", stdout);
@@ -495,7 +496,7 @@ doshortlink(const char *begin, const char *end, int newbloc…
fprintf(stdout, "&#%u;", *c);
}
else {
- hprint(begin + 1, p);
+ hprintattr(begin + 1, p);
fputs("\">", stdout);
hprint(begin + 1, p);
}
@@ -585,7 +586,7 @@ ereallocz(void *p, size_t size) {
}
void
-hprint(const char *begin, const char *end) {
+hprintattr(const char *begin, const char *end) {
const char *p;
for(p = begin; p != end; p++) {
@@ -603,6 +604,22 @@ hprint(const char *begin, const char *end) {
}
void
+hprint(const char *begin, const char *end) {
+ const char *p;
+
+ for(p = begin; p != end; p++) {
+ if(*p == '&')
+ fputs("&amp;", stdout);
+ else if(*p == '>')
+ fputs("&gt;", stdout);
+ else if(*p == '<')
+ fputs("&lt;", stdout);
+ else
+ fputc(*p, stdout);
+ }
+}
+
+void
process(const char *begin, const char *end, int newblock) {
const char *p, *q;
int affected;
You are viewing proxied material from codemadness.org. The copyright of proxied material belongs to its original authors. Any comments or complaints in relation to proxied material should be directed to the original authors of the content concerned. Please see the disclaimer for more details.