summaryrefslogtreecommitdiffstats
path: root/net/base/escape.h
diff options
context:
space:
mode:
authormrossetti@chromium.org <mrossetti@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-04-13 00:45:39 +0000
committermrossetti@chromium.org <mrossetti@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-04-13 00:45:39 +0000
commita47f8eadd67f75d3b663fdcc898caabb335bad0b (patch)
treefdf872770d4cd58ee753f219475850490a008f6d /net/base/escape.h
parent2e0e8253a232fa499d22e47753c5bbadaebd69e7 (diff)
downloadchromium_src-a47f8eadd67f75d3b663fdcc898caabb335bad0b.zip
chromium_src-a47f8eadd67f75d3b663fdcc898caabb335bad0b.tar.gz
chromium_src-a47f8eadd67f75d3b663fdcc898caabb335bad0b.tar.bz2
Add multiple-offset versions of the various URL reformatting functions. Fixed a couple of erroneous unit tests of offsets into username/password.
Note: This does not complete the work required for 78153 -- tis but the first 2/3rds. BUG=78153 TEST=Many unit tests updated and added. Review URL: http://codereview.chromium.org/6822038 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@81343 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net/base/escape.h')
-rw-r--r--net/base/escape.h31
1 files changed, 25 insertions, 6 deletions
diff --git a/net/base/escape.h b/net/base/escape.h
index faa7bd3..f4c99a3 100644
--- a/net/base/escape.h
+++ b/net/base/escape.h
@@ -7,6 +7,7 @@
#pragma once
#include <string>
+#include <vector>
#include "base/basictypes.h"
#include "base/string16.h"
@@ -99,15 +100,20 @@ string16 UnescapeURLComponent(const string16& escaped_text,
// Unescapes the given substring as a URL, and then tries to interpret the
// result as being encoded as UTF-8. If the result is convertable into UTF-8, it
// will be returned as converted. If it is not, the original escaped string will
-// be converted into a string16 and returned.
-//
-// |offset_for_adjustment| may be NULL; if not, it is an offset into |text| that
-// will be adjusted to point at the same logical place in the result string. If
-// this isn't possible because it points into the middle of an escape sequence
-// or past the end of the string, it will be set to string16::npos.
+// be converted into a string16 and returned. (|offset[s]_for_adjustment|)
+// specifies one or more offsets into the source strings; each offset will be
+// adjusted to point at the same logical place in the result strings during
+// decoding. If this isn't possible because an offset points past the end of
+// the source strings or into the middle of a multibyte sequence, the offending
+// offset will be set to std::wstring::npos. |offset[s]_for_adjustment| may be
+// NULL.
string16 UnescapeAndDecodeUTF8URLComponent(const std::string& text,
UnescapeRule::Type rules,
size_t* offset_for_adjustment);
+string16 UnescapeAndDecodeUTF8URLComponentWithOffsets(
+ const std::string& text,
+ UnescapeRule::Type rules,
+ std::vector<size_t>* offsets_for_adjustment);
// Unescape the following ampersand character codes from |text|:
// &lt; &gt; &amp; &quot; &#39;
@@ -129,4 +135,17 @@ bool EscapeQueryParamValue(const string16& text, const char* codepage,
// assumes the codepage is UTF8. This is provided as a convenience.
string16 EscapeQueryParamValueUTF8(const string16& text, bool use_plus);
+// Private Functions (Exposed for Unit Testing) --------------------------------
+
+// A function called by std::for_each that will adjust any offset which occurs
+// after one or more encoded characters.
+struct AdjustEncodingOffset {
+ typedef std::vector<size_t> Adjustments;
+
+ explicit AdjustEncodingOffset(const Adjustments& adjustments);
+ void operator()(size_t& offset);
+
+ const Adjustments& adjustments;
+};
+
#endif // NET_BASE_ESCAPE_H_