1 // Copyright 2019 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #include "pdf/out_of_process_instance.h"
9 #include "testing/gtest/include/gtest/gtest.h"
11 namespace chrome_pdf {
13 TEST(OutOfProcessInstanceTest, GetFileNameFromUrl) {
15 OutOfProcessInstance::GetFileNameFromUrl("https://test/a/b.pdf"));
17 // File extensions should be kept as-is.
19 OutOfProcessInstance::GetFileNameFromUrl("https://test/a/b.hat"));
21 // Most escaped characters should be unescaped.
22 EXPECT_EQ("a b.pdf", OutOfProcessInstance::GetFileNameFromUrl(
23 "https://test/%61%20b.pdf"));
25 // Escaped file path delimiters and control codes should be replaced by a
27 EXPECT_EQ("a_b_.pdf", OutOfProcessInstance::GetFileNameFromUrl(
28 "https://test/a%2Fb%01.pdf"));
30 // UTF-8 characters, including ones left escaped by UnescapeURLComponent() for
31 // security reasons, are allowed in file paths.
32 EXPECT_EQ("\xF0\x9F\x94\x92", OutOfProcessInstance::GetFileNameFromUrl(
33 "https://test/%F0%9F%94%92"));
36 } // namespace chrome_pdf