From e78336c21fded6d195d3ee0892894d475f77f692 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Niels=20M=C3=B6ller?= Date: Fri, 15 Dec 2017 14:53:13 +0100 Subject: [PATCH] Delete HttpComposeAttributes. Bug: webrtc:6424 Change-Id: Ie11def7aed5cf7721e43f23e500bdc593385b2cb Reviewed-on: https://webrtc-review.googlesource.com/33361 Reviewed-by: Taylor Brandstetter Commit-Queue: Niels Moller Cr-Commit-Position: refs/heads/master@{#21314} --- rtc_base/httpcommon.cc | 27 --------------------------- rtc_base/stringencode.cc | 22 ---------------------- rtc_base/stringencode.h | 8 -------- 3 files changed, 57 deletions(-) diff --git a/rtc_base/httpcommon.cc b/rtc_base/httpcommon.cc index 7667faf546..5f2112ac1a 100644 --- a/rtc_base/httpcommon.cc +++ b/rtc_base/httpcommon.cc @@ -29,8 +29,6 @@ #include "rtc_base/httpcommon.h" #include "rtc_base/messagedigest.h" #include "rtc_base/socketaddress.h" -#include "rtc_base/stringencode.h" -#include "rtc_base/stringutils.h" namespace rtc { @@ -223,33 +221,8 @@ inline bool IsEndOfAttributeName(size_t pos, size_t len, const char * data) { return false; } -// TODO: unittest for EscapeAttribute and HttpComposeAttributes. - -std::string EscapeAttribute(const std::string& attribute) { - const size_t kMaxLength = attribute.length() * 2 + 1; - char* buffer = STACK_ARRAY(char, kMaxLength); - size_t len = escape(buffer, kMaxLength, attribute.data(), attribute.length(), - "\"", '\\'); - return std::string(buffer, len); -} - } // anonymous namespace -void HttpComposeAttributes(const HttpAttributeList& attributes, char separator, - std::string* composed) { - std::stringstream ss; - for (size_t i=0; i 0) { - ss << separator << " "; - } - ss << attributes[i].first; - if (!attributes[i].second.empty()) { - ss << "=\"" << EscapeAttribute(attributes[i].second) << "\""; - } - } - *composed = ss.str(); -} - void HttpParseAttributes(const char * data, size_t len, HttpAttributeList& attributes) { size_t pos = 0; diff --git a/rtc_base/stringencode.cc b/rtc_base/stringencode.cc index d77245f5d6..755cb2ca02 100644 --- a/rtc_base/stringencode.cc +++ b/rtc_base/stringencode.cc @@ -22,28 +22,6 @@ namespace rtc { // String Encoding Utilities ///////////////////////////////////////////////////////////////////////////// -size_t escape(char * buffer, size_t buflen, - const char * source, size_t srclen, - const char * illegal, char escape) { - RTC_DCHECK(buffer); // TODO(grunell): estimate output size - if (buflen <= 0) - return 0; - - size_t srcpos = 0, bufpos = 0; - while ((srcpos < srclen) && (bufpos + 1 < buflen)) { - char ch = source[srcpos++]; - if ((ch == escape) || ::strchr(illegal, ch)) { - if (bufpos + 2 >= buflen) - break; - buffer[bufpos++] = escape; - } - buffer[bufpos++] = ch; - } - - buffer[bufpos] = '\0'; - return bufpos; -} - size_t url_decode(char * buffer, size_t buflen, const char * source, size_t srclen) { if (nullptr == buffer) diff --git a/rtc_base/stringencode.h b/rtc_base/stringencode.h index 5d675a2598..e5395b7edf 100644 --- a/rtc_base/stringencode.h +++ b/rtc_base/stringencode.h @@ -23,14 +23,6 @@ namespace rtc { // String Encoding Utilities ////////////////////////////////////////////////////////////////////// -// TODO(nisse): Used only in httpcommon.c. Delete when that file is deleted, or -// possibly if the HttpComposeAttributes funtion can be deleted earlier. -// Escaping prefixes illegal characters with the escape character. Compact, but -// illegal characters still appear in the string. -size_t escape(char * buffer, size_t buflen, - const char * source, size_t srclen, - const char * illegal, char escape); - // Note: in-place decoding (buffer == source) is allowed. size_t url_decode(char * buffer, size_t buflen, const char * source, size_t srclen);