diff options
author | zea@chromium.org <zea@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-03-12 05:17:29 +0000 |
---|---|---|
committer | zea@chromium.org <zea@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-03-12 05:17:29 +0000 |
commit | 807c6597d34336d8af58995ee4fd1489cc88b007 (patch) | |
tree | 366474a8e55fec37451705153e82e3b0a910d867 /sync/internal_api/syncapi_internal.cc | |
parent | e512c79c74ff343b1459dc607d45cb8ea8e68c26 (diff) | |
download | chromium_src-807c6597d34336d8af58995ee4fd1489cc88b007.zip chromium_src-807c6597d34336d8af58995ee4fd1489cc88b007.tar.gz chromium_src-807c6597d34336d8af58995ee4fd1489cc88b007.tar.bz2 |
[Sync] Fix long bookmark title syncing
Sync internally performs some truncation on bookmark titles if they are too
long. This means though that the association logic will look at the truncated
and non-truncated versions and decide they are different bookmarks, resulting
in duplication. We fix this by performing the same truncation at bookmark
comparison time in the associator.
BUG=334537
Review URL: https://codereview.chromium.org/179053004
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@256441 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'sync/internal_api/syncapi_internal.cc')
-rw-r--r-- | sync/internal_api/syncapi_internal.cc | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/sync/internal_api/syncapi_internal.cc b/sync/internal_api/syncapi_internal.cc index a6530ac..d297fcb 100644 --- a/sync/internal_api/syncapi_internal.cc +++ b/sync/internal_api/syncapi_internal.cc @@ -11,6 +11,14 @@ namespace syncer { +namespace { + +bool EndsWithSpace(const std::string& string) { + return !string.empty() && *string.rbegin() == ' '; +} + +} + sync_pb::PasswordSpecificsData* DecryptPasswordSpecifics( const sync_pb::EntitySpecifics& specifics, Cryptographer* crypto) { if (!specifics.has_password()) @@ -38,6 +46,20 @@ void SyncAPINameToServerName(const std::string& syncer_name, out->append(" "); } +// In the reverse direction, if a server name matches the pattern of a +// server-illegal name followed by one or more spaces, remove the trailing +// space. +void ServerNameToSyncAPIName(const std::string& server_name, + std::string* out) { + CHECK(out); + int length_to_copy = server_name.length(); + if (IsNameServerIllegalAfterTrimming(server_name) && + EndsWithSpace(server_name)) { + --length_to_copy; + } + *out = server_name.substr(0, length_to_copy); +} + // Checks whether |name| is a server-illegal name followed by zero or more space // characters. The three server-illegal names are the empty string, dot, and // dot-dot. Very long names (>255 bytes in UTF-8 Normalization Form C) are |