Skip to content

Commit

Permalink
Custom Margins: Default to 0 for missing values
Browse files Browse the repository at this point in the history
Tolerate non-existent custom margins values in C++, by setting the
margin field to 0 if it does not exist. This will prevent the crashes
in the linked bug, and is safer than merging larger changes to the
Print Preview JS that will prevent this from happening.

This is a short term workaround; we will change this back to a stricter
check after landing larger changes in Print Preview JS to prevent bad
custom margin values from being sent.

Bug: 942211
Change-Id: I978fdf65519efc0d6a0d6379c2266e330908fc0d
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1529314
Reviewed-by: Lei Zhang <thestig@chromium.org>
Commit-Queue: Lei Zhang <thestig@chromium.org>
Cr-Commit-Position: refs/heads/master@{#642002}
  • Loading branch information
rbpotter authored and Commit Bot committed Mar 19, 2019
1 parent 285c0a3 commit 9f1465f
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions printing/print_settings_conversion.cc
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,13 @@ void GetCustomMarginsFromJobSettings(const base::Value& settings,
return;
}
page_size_margins->top =
custom_margins->FindKey(kSettingMarginTop)->GetDouble();
custom_margins->FindIntKey(kSettingMarginTop).value_or(0);
page_size_margins->bottom =
custom_margins->FindKey(kSettingMarginBottom)->GetDouble();
custom_margins->FindIntKey(kSettingMarginBottom).value_or(0);
page_size_margins->left =
custom_margins->FindKey(kSettingMarginLeft)->GetDouble();
custom_margins->FindIntKey(kSettingMarginLeft).value_or(0);
page_size_margins->right =
custom_margins->FindKey(kSettingMarginRight)->GetDouble();
custom_margins->FindIntKey(kSettingMarginRight).value_or(0);
}

void SetMarginsToJobSettings(const std::string& json_path,
Expand Down

0 comments on commit 9f1465f

Please sign in to comment.