diff --git a/src/document/html/parser/parse.c b/src/document/html/parser/parse.c index 46e636f8f..135f64599 100644 --- a/src/document/html/parser/parse.c +++ b/src/document/html/parser/parse.c @@ -211,7 +211,7 @@ found_endattr: mem_free(saved_attr); } - set_mem_comment(trim_chars(attr, ' ', NULL), name, strlen(name)); + set_mem_comment(attr, name, strlen(name)); return attr; } else { diff --git a/src/protocol/common.c b/src/protocol/common.c index c21dc42ca..d22fd84b1 100644 --- a/src/protocol/common.c +++ b/src/protocol/common.c @@ -47,12 +47,14 @@ enum connection_state init_directory_listing(struct string *page, struct uri *uri) { struct string dirpath = NULL_STRING; + struct string decoded = NULL_STRING; struct string location = NULL_STRING; unsigned char *info; int local = (uri->protocol == PROTOCOL_FILE); if (!init_string(page) || !init_string(&dirpath) + || !init_string(&decoded) || !init_string(&location) || !add_uri_to_string(&dirpath, uri, URI_DATA) || !add_uri_to_string(&location, uri, URI_DIR_LOCATION)) @@ -63,12 +65,12 @@ init_directory_listing(struct string *page, struct uri *uri) && !add_char_to_string(&dirpath, local ? CHAR_DIR_SEP : '/')) goto out_of_memory; - if (local || uri->protocol == PROTOCOL_FSP || uri->protocol == PROTOCOL_GOPHER - || uri->protocol == PROTOCOL_SMB) { - /* A little hack to get readable Gopher names. We should find a - * way to do it more general. */ - decode_uri_string(&dirpath); - } + /* Decode uri for displaying. Do not use + * add_string_to_string, because it for some reason returns + * NULL if the second string is empty. */ + if (!add_bytes_to_string(&decoded, dirpath.source, dirpath.length)) + goto out_of_memory; + decode_uri_string(&decoded); if (!local && !add_char_to_string(&location, '/')) goto out_of_memory; @@ -76,23 +78,15 @@ init_directory_listing(struct string *page, struct uri *uri) if (!add_to_string(page, "\n