commit fcf1b61: [Minor] Fix parsing of URLs with displayed UTF characters

Vsevolod Stakhov vsevolod at highsecure.ru
Mon Feb 25 12:49:03 UTC 2019


Author: Vsevolod Stakhov
Date: 2019-02-25 12:48:18 +0000
URL: https://github.com/rspamd/rspamd/commit/fcf1b617ed850e7cbab47b37b37eda6a7db3b52c (HEAD -> master)

[Minor] Fix parsing of URLs with displayed UTF characters

---
 src/libserver/url.c | 19 +++++++++++--------
 1 file changed, 11 insertions(+), 8 deletions(-)

diff --git a/src/libserver/url.c b/src/libserver/url.c
index 4e1b9f3d2..13c324e7a 100644
--- a/src/libserver/url.c
+++ b/src/libserver/url.c
@@ -1021,11 +1021,13 @@ rspamd_web_parse (struct http_parser_url *u, const gchar *str, gsize len,
 									(*flags) |= RSPAMD_URL_FLAG_OBSCURED;
 								}
 								else {
-									if (!(parse_flags & RSPAMD_URL_PARSE_CHECK)) {
-										goto out;
-									}
-									else {
-										goto set;
+									if (!u_isgraph (uc)) {
+										if (!(parse_flags & RSPAMD_URL_PARSE_CHECK)) {
+											goto out;
+										}
+										else {
+											goto set;
+										}
 									}
 								}
 							}
@@ -3284,10 +3286,11 @@ rspamd_url_encode (struct rspamd_url *url, gsize *pdlen,
 	d = dest;
 	dend = d + dlen;
 
-	if (url->protocollen > 0 &&
-		(url->protocol >= 0 && url->protocol < G_N_ELEMENTS (rspamd_url_protocols))) {
+	if (url->protocollen > 0) {
 		d += rspamd_snprintf ((gchar *) d, dend - d,
-				"%*s://", url->protocollen, rspamd_url_protocols[url->protocol].name);
+				"%*s://",
+				url->protocollen,
+				rspamd_url_protocol_name (url->protocol));
 	}
 	else {
 		d += rspamd_snprintf ((gchar *) d, dend - d, "http://");


More information about the Commits mailing list