Commit 58dd2431 authored by Piotr Pawliczek's avatar Piotr Pawliczek Committed by Commit Bot

Omit a queue name in a "socket://" printer URI

Printer URIs with a "socket" protocol cannot have a path component.
However, our UI allows a user to provide a queue name (a path) for all
types of printers. Moreover, this field has a non-empty default value.
This causes a validation error of provided printer URIs with a "socket"
protocol when a user doesn't clean the field by hand. This patch solves
the problem by automatically removing a path component from provided
URI when the protocol is set to "socket".

BUG=chromium:1129047
TEST=tested on atlas

Change-Id: I92d8afbaaf4f0e74d102b1384ef7378d34b15496
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2423344
Commit-Queue: Piotr Pawliczek <pawliczek@chromium.org>
Auto-Submit: Piotr Pawliczek <pawliczek@chromium.org>
Reviewed-by: default avatarZentaro Kavanagh <zentaro@chromium.org>
Cr-Commit-Position: refs/heads/master@{#810072}
parent e95457a8
...@@ -147,10 +147,13 @@ std::unique_ptr<chromeos::Printer> DictToPrinter( ...@@ -147,10 +147,13 @@ std::unique_ptr<chromeos::Printer> DictToPrinter(
} }
std::string printer_queue; std::string printer_queue;
printer_dict.GetString("printerQueue", &printer_queue); // The protocol "socket" does not allow path.
// Path must start from '/' character. if (printer_protocol != "socket") {
if (!printer_queue.empty() && printer_queue.front() != '/') printer_dict.GetString("printerQueue", &printer_queue);
printer_queue = "/" + printer_queue; // Path must start from '/' character.
if (!printer_queue.empty() && printer_queue.front() != '/')
printer_queue.insert(0, "/");
}
auto printer = std::make_unique<chromeos::Printer>(printer_id); auto printer = std::make_unique<chromeos::Printer>(printer_id);
printer->set_display_name(printer_name); printer->set_display_name(printer_name);
......
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