]> source.dussan.org Git - rspamd.git/commitdiff
[Minor] Fix some issues found
authorVsevolod Stakhov <vsevolod@highsecure.ru>
Fri, 22 Jan 2021 15:49:38 +0000 (15:49 +0000)
committerVsevolod Stakhov <vsevolod@highsecure.ru>
Fri, 22 Jan 2021 15:58:05 +0000 (15:58 +0000)
src/libserver/css/css_parser.cxx

index 99798b8443c9413f94e34ca2110f17e8b0d14aa5..4134b933cef62bbae1a79b9720e8f5c908680b40 100644 (file)
@@ -155,23 +155,23 @@ css_parser::unescape_css(const std::string_view &sv)
                                        const auto *escape_start = &sv[escape_offset + 1];
                                        unsigned long val;
 
-                                       if (!rspamd_xstrtoul (escape_start, i - escape_offset - 1, &val)) {
+                                       if (!rspamd_xstrtoul(escape_start, i - escape_offset - 1, &val)) {
                                                msg_debug_css("invalid broken escape found at pos %d",
                                                                escape_offset);
                                        }
                                        else {
-                                               if (val < 0x1f) {
+                                               if (val < 0x80) {
                                                        /* Trivial case: ascii character */
                                                        *d++ = (unsigned char)val;
                                                        nleft --;
                                                }
                                                else {
                                                        UChar32 uc = val;
-                                                       auto off = d - nspace;
+                                                       auto off = 0;
                                                        UTF8_APPEND_CHAR_SAFE((uint8_t *) d, off,
                                                                        sv.length (), uc);
-                                                       d = nspace + off;
-                                                       nleft = sv.length () - off;
+                                                       d += off;
+                                                       nleft -= off;
                                                }
                                        }
                                }
@@ -181,7 +181,7 @@ css_parser::unescape_css(const std::string_view &sv)
                                                        escape_offset);
                                }
 
-                               if (nleft > 0) {
+                               if (nleft <= 0) {
                                        msg_err_css("cannot unescape css: truncated buffer of size %d",
                                                        (int)sv.length());
                                }