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 | |
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')
-rw-r--r-- | sync/internal_api/base_node.cc | 18 | ||||
-rw-r--r-- | sync/internal_api/syncapi_internal.cc | 22 | ||||
-rw-r--r-- | sync/internal_api/syncapi_internal.h | 4 |
3 files changed, 25 insertions, 19 deletions
diff --git a/sync/internal_api/base_node.cc b/sync/internal_api/base_node.cc index 887e642..ac04768 100644 --- a/sync/internal_api/base_node.cc +++ b/sync/internal_api/base_node.cc @@ -40,24 +40,6 @@ static int64 IdToMetahandle(syncable::BaseTransaction* trans, return entry.GetMetahandle(); } -static bool EndsWithSpace(const std::string& string) { - return !string.empty() && *string.rbegin() == ' '; -} - -// 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. -static 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 = std::string(server_name.c_str(), length_to_copy); -} - BaseNode::BaseNode() : password_data_(new sync_pb::PasswordSpecificsData) {} BaseNode::~BaseNode() {} 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 diff --git a/sync/internal_api/syncapi_internal.h b/sync/internal_api/syncapi_internal.h index 06689aad..27e1400 100644 --- a/sync/internal_api/syncapi_internal.h +++ b/sync/internal_api/syncapi_internal.h @@ -25,8 +25,10 @@ sync_pb::PasswordSpecificsData* DecryptPasswordSpecifics( const sync_pb::EntitySpecifics& specifics, Cryptographer* crypto); -SYNC_EXPORT_PRIVATE void SyncAPINameToServerName(const std::string& syncer_name, +SYNC_EXPORT void SyncAPINameToServerName(const std::string& syncer_name, std::string* out); +SYNC_EXPORT void ServerNameToSyncAPIName(const std::string& server_name, + std::string* out); bool IsNameServerIllegalAfterTrimming(const std::string& name); |