
Split from: https://chromium-review.googlesource.com/c/chromium/src/+/6004959 Generated patch --------------- - Tool: ./tool/clang/spanify/rewrite-multiple-platform.sh - Platform: Linux. - Filter: This includes 2400/4222 patches. I included the std::array ones and excluded build errors. Google announcement: -------------------- https://groups.google.com/a/google.com/g/chrome-memory-safety/c/RMiO4gaVLQA/m/Yz-3NCObAgAJ Benchmarks: ---------- See design doc and https://chromium-review.googlesource.com/c/chromium/src/+/6004959/21 Description ----------- The consensus during the memory safety summit was to begin rewriting relevant C-style arrays to C++11 std::array. It can be done immediately, offers better developer ergonomics, and fix large chunks of the -Wunsafe-buffer-usage errors in Chrome. To clarify, this effort is complementary to the longer plan work with enabling -fsanitize=array-bounds, and we plan to leverage both, especially for protecting 3p code. [Attached] is a document detailing the rationale, benefits, and considerations for potential compile-time and performance impacts. [Attached]:https://docs.google.com/document/d/1z5aBDg26lHmNDjXRCysElWKx7E4PAJXqykI_k7ondJI/edit?tab=t.0#heading=h.cqgo7wvp0kzt NO_IFTTT=No need to update base/debug/stack_trace.h Bug: 378069401 Change-Id: I6d36543c267f12c672cce00d75cf833fff238ebf R: dcheng@chromium.org AX-Relnotes: n/a. Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6039265 Reviewed-by: Daniel Cheng <dcheng@chromium.org> Auto-Submit: Arthur Sonzogni <arthursonzogni@chromium.org> Commit-Queue: Arthur Sonzogni <arthursonzogni@chromium.org> Owners-Override: Daniel Cheng <dcheng@chromium.org> Cr-Commit-Position: refs/heads/main@{#1395908}
48 lines
1.5 KiB
C++
48 lines
1.5 KiB
C++
// Copyright 2012 The Chromium Authors
|
|
// Use of this source code is governed by a BSD-style license that can be
|
|
// found in the LICENSE file.
|
|
|
|
|
|
#include "content/public/common/webplugininfo.h"
|
|
|
|
#include <stddef.h>
|
|
|
|
#include <array>
|
|
#include <memory>
|
|
#include <string>
|
|
#include <vector>
|
|
|
|
#include "base/strings/utf_string_conversions.h"
|
|
#include "base/version.h"
|
|
#include "testing/gtest/include/gtest/gtest.h"
|
|
|
|
namespace content {
|
|
|
|
TEST(PluginUtilsTest, VersionExtraction) {
|
|
// Some real-world plugin versions (spaces, commata, parentheses, 'r', oh my)
|
|
auto versions = std::to_array<std::array<const char*, 2>>({
|
|
{"7.6.6 (1671)", "7.6.6.1671"}, // Quicktime
|
|
{"2, 0, 0, 254", "2.0.0.254"}, // DivX
|
|
{"3, 0, 0, 0", "3.0.0.0"}, // Picasa
|
|
{"1, 0, 0, 1", "1.0.0.1"}, // Earth
|
|
{"10,0,45,2", "10.0.45.2"}, // Flash
|
|
{"10.1 r102", "10.1.102"}, // Flash
|
|
{"10.3 d180", "10.3.180"}, // Flash (Debug)
|
|
{"11.5.7r609", "11.5.7.609"}, // Shockwave
|
|
{"1.6.0_22", "1.6.0.22"}, // Java
|
|
{"1.07.00_0005", "1.7.0.5"}, // Java with leading zeros
|
|
{"1..0", "1.0.0"} // Empty version component
|
|
});
|
|
|
|
for (size_t i = 0; i < std::size(versions); i++) {
|
|
base::Version version;
|
|
WebPluginInfo::CreateVersionFromString(
|
|
base::ASCIIToUTF16(versions[i][0]), &version);
|
|
|
|
ASSERT_TRUE(version.IsValid());
|
|
EXPECT_EQ(versions[i][1], version.GetString());
|
|
}
|
|
}
|
|
|
|
} // namespace content
|