Commit 05d610bf authored by Sorin Jianu's avatar Sorin Jianu Committed by Commit Bot

Fix UpdateClient XML serialization when <disabled> reasons are present.

The buggy code serializes the <disabled> tag before closing the
<app> tag, like this:

<app appid=...version="0.9" brand="TEST" enabled="0"<disabled reason="0"/>

Bug: 901497
Change-Id: I2106ee35e99dd9c7fa66baab0c0efdc4942cab05
Reviewed-on: https://chromium-review.googlesource.com/c/1316441Reviewed-by: default avatarMinh Nguyen <mxnguyen@chromium.org>
Commit-Queue: Sorin Jianu <sorin@chromium.org>
Cr-Commit-Position: refs/heads/master@{#605113}
parent 5f880396
...@@ -96,6 +96,7 @@ std::string ProtocolSerializerXml::Serialize( ...@@ -96,6 +96,7 @@ std::string ProtocolSerializerXml::Serialize(
#endif #endif
for (const auto& app : request.apps) { for (const auto& app : request.apps) {
// Begin <app> attributes.
base::StringAppendF(&msg, "<app appid=\"%s\"", app.app_id.c_str()); base::StringAppendF(&msg, "<app appid=\"%s\"", app.app_id.c_str());
base::StringAppendF(&msg, " version=\"%s\"", app.version.c_str()); base::StringAppendF(&msg, " version=\"%s\"", app.version.c_str());
if (!app.brand_code.empty()) if (!app.brand_code.empty())
...@@ -118,16 +119,16 @@ std::string ProtocolSerializerXml::Serialize( ...@@ -118,16 +119,16 @@ std::string ProtocolSerializerXml::Serialize(
base::StringAppendF(&msg, " cohortname=\"%s\"", app.cohort_name.c_str()); base::StringAppendF(&msg, " cohortname=\"%s\"", app.cohort_name.c_str());
if (!app.cohort_hint.empty()) if (!app.cohort_hint.empty())
base::StringAppendF(&msg, " cohorthint=\"%s\"", app.cohort_hint.c_str()); base::StringAppendF(&msg, " cohorthint=\"%s\"", app.cohort_hint.c_str());
if (app.enabled) if (app.enabled)
base::StringAppendF(&msg, " enabled=\"%d\"", *app.enabled ? 1 : 0); base::StringAppendF(&msg, " enabled=\"%d\"", *app.enabled ? 1 : 0);
base::StringAppendF(&msg, ">");
// End <app> attributes.
if (app.disabled_reasons) { if (app.disabled_reasons) {
for (const int disabled_reason : *app.disabled_reasons) for (const int disabled_reason : *app.disabled_reasons)
base::StringAppendF(&msg, "<disabled reason=\"%d\"/>", disabled_reason); base::StringAppendF(&msg, "<disabled reason=\"%d\"/>", disabled_reason);
} }
base::StringAppendF(&msg, ">");
if (app.update_check) { if (app.update_check) {
base::StringAppendF(&msg, "<updatecheck"); base::StringAppendF(&msg, "<updatecheck");
if (app.update_check->is_update_disabled) if (app.update_check->is_update_disabled)
...@@ -186,6 +187,7 @@ std::string ProtocolSerializerXml::Serialize( ...@@ -186,6 +187,7 @@ std::string ProtocolSerializerXml::Serialize(
base::StringAppendF(&msg, "/>"); base::StringAppendF(&msg, "/>");
} }
} }
base::StringAppendF(&msg, "</app>"); base::StringAppendF(&msg, "</app>");
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment