summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorGravatar fab <fabrice.leal.ch@gmail.com>2018-12-02 20:58:02 +0000
committerGravatar fab <fabrice.leal.ch@gmail.com>2018-12-02 20:58:02 +0000
commitbc1547efbbad30da255b7c29973c94c8d37edabc (patch)
treeb374da910584a126f94523fe895c1658c9db0015 /src
parentb50f472e65c0ffca5d485049325caa51298daa1a (diff)
fix: U8_IS_SINGLE should only be called on raw char*, NOT on uw_Basis_char
Diffstat (limited to 'src')
-rw-r--r--src/c/urweb.c20
1 files changed, 10 insertions, 10 deletions
diff --git a/src/c/urweb.c b/src/c/urweb.c
index a4203376..d622df87 100644
--- a/src/c/urweb.c
+++ b/src/c/urweb.c
@@ -2321,18 +2321,17 @@ uw_unit uw_Basis_jsifyInt_w(uw_context ctx, uw_Basis_int n) {
char *uw_Basis_htmlifyString(uw_context ctx, const char *s) {
char *r, *s2;
uw_Basis_char c1;
- int offset = 0, len = 0;
+ int oldoffset = 0, offset = 0, offset2 = 0, len = 0;
uw_check_heap(ctx, strlen(s) * (INTS_MAX + 3) + 1);
r = s2 = ctx->heap.front;
while (s[offset] != 0) {
-
+ oldoffset = offset;
U8_NEXT(s, offset, -1, c1);
-
-
- if (U8_IS_SINGLE(c1) && uw_Basis_isprint(ctx, c1)) {
+
+ if ((offset - oldoffset == 1) && uw_Basis_isprint(ctx, c1)) {
switch (c1) {
case '<':
strcpy(s2, "&lt;");
@@ -2343,7 +2342,9 @@ char *uw_Basis_htmlifyString(uw_context ctx, const char *s) {
s2 += 5;
break;
default:
- *s2++ = c1;
+ offset2 = 0;
+ U8_APPEND_UNSAFE(s2, offset2, c1);
+ s2 += offset2;
}
} else {
len = sprintf(s2, "&#%u;", c1);
@@ -2353,20 +2354,19 @@ char *uw_Basis_htmlifyString(uw_context ctx, const char *s) {
*s2++ = 0;
ctx->heap.front = s2;
-
return r;
}
uw_unit uw_Basis_htmlifyString_w(uw_context ctx, uw_Basis_string s) {
uw_check(ctx, strlen(s) * 6);
- int offset = 0;
+ int offset = 0, oldoffset = 0;
uw_Basis_char c1;
while(s[offset] != 0){
-
+ oldoffset = offset;
U8_NEXT(s, offset, -1, c1);
- if (U8_IS_SINGLE(c1) && uw_Basis_isprint(ctx, c1)) {
+ if ((offset - oldoffset == 1) && uw_Basis_isprint(ctx, c1)) {
switch (c1) {
case '<':