Skip to content
Open
Show file tree
Hide file tree
Changes from 34 commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
c4d78c1
Internal Code Change
a-googler Jun 14, 2023
f4fd254
Fixed lint errors for license.
banaag Jun 27, 2023
dbd5f13
Various lint fixes.
amaltas Aug 9, 2023
b06f8f3
Few more lint errors/warnings fixes.
amaltas Aug 9, 2023
4fd05a9
Create announce mailing list to notify important updates to clients.
amaltas Aug 16, 2023
131a63b
Mark htmlparser Node.DebugString as const.
a-googler Aug 18, 2023
c9c47c4
No description.
a-googler Nov 14, 2023
a17c5b1
Automated Code Change
a-googler Jan 16, 2024
fee2792
Add a missing include for `std::alignment_of_v`
a-googler Feb 5, 2024
3696813
Internal cleanup.
amaltas Feb 5, 2024
b384f42
Split htmlparser README in internal and externals.
amaltas Feb 5, 2024
60663e0
Automated Code Change
a-googler Feb 27, 2024
1e1f518
Fix tokenization of HTML tag attributes for the edge case of attribut…
a-googler Feb 27, 2024
dfe4bff
Remove unused dependency by using c++ attribute [[fallthrough]] inste…
amaltas Feb 27, 2024
b1cb77b
Fix tokenization of HTML tag attributes for the edge case of attribut…
a-googler Mar 11, 2024
5391e42
Fix rendering of RAWTEXT nodes.
a-googler Mar 21, 2024
0eecb00
Automated Code Change
a-googler Jun 3, 2024
2131a4c
Internal change.
a-googler Jun 17, 2024
491e00d
cleans up JsonDict and JsonArray
a-googler Jul 18, 2024
fb008e4
Add `const` iterators to `htmlparser::Document` to allow range-based …
a-googler Jul 29, 2024
a6feb62
No description.
a-googler Oct 30, 2024
3303a69
Fix parsing of RawOrRCDATA
a-googler Dec 9, 2024
7a31297
Fix end tag parsing
a-googler Dec 9, 2024
694cafc
Support unescaping decimal single digit html codes.
a-googler Mar 18, 2025
2c44e1e
Use string_view instead of copying string in UnescapeEntity. When the…
a-googler Mar 18, 2025
fede34a
Initialize Token struct token_type and atom explicitly.
a-googler Mar 24, 2025
0aae564
Reduce allocs for variadic homogeneous arguments and for known sized …
a-googler Mar 25, 2025
3b7f656
Having a trailing comma in function call arguments is invalid C++ cod…
a-googler Mar 25, 2025
6413057
Reduce some allocs from TagAttr in Tokenizer.
a-googler Mar 25, 2025
2973255
Restore previous build from this pull request
amaltas Mar 28, 2025
b697944
Restoring validator-internal.cc
amaltas Mar 28, 2025
d5b4eb5
Update validator_test.cc
amaltas Mar 28, 2025
62a0b8b
Update WORKSPACE
amaltas Mar 28, 2025
7173515
Disable validator tests in circleci flow
amaltas Mar 28, 2025
743cecb
Update config.yml
amaltas Apr 1, 2025
ea5e935
Skip validator tests if htmlparser only changes
amaltas Apr 1, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 0 additions & 18 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -289,19 +289,6 @@ jobs:
name: '⭐⭐⭐ Bundle Size ⭐⭐⭐'
command: node build-system/pr-check/bundle-size.js
- teardown_vm
validator_tests:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@banaag can you give an LGTM on this part, or do we need it back?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@amaltas why are we turning off the validator tests? is this temporary?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Amaltas says it's just temporary, we can reactivate after submission of the PR

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@amaltas instead of disabling all validator tests, can you try changing this line here

if (isOwnersFile(file) || file.startsWith('validator/js/webui/')) {

you can try adding file.startsWith('validator/cpp/htmlparser/'). This will at least only exclude the htmlparser changes from triggering the validator.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unfortunately this didn't work.

executor:
name: jdk-docker-2xlarge
steps:
- setup_vm
- run:
name: 'Install Validator Dependencies'
command: ./.circleci/install_validator_dependencies.sh
- run:
name: '⭐⭐⭐ Validator Tests ⭐⭐⭐'
command: node build-system/pr-check/validator-tests.js
- store_test_output
- teardown_vm
visual_diff_tests:
executor:
name: node-docker-large
Expand Down Expand Up @@ -565,11 +552,6 @@ workflows:
- 'Nomodule 3p Build (Bundle Size)'
- '⛓️ Module Build (Bundle Size)'
- 'Module 3p Build (Bundle Size)'
- validator_tests:
name: 'Validator Tests'
<<: *push_and_pr_builds
requires:
- 'Initialize Repository'
- visual_diff_tests:
name: 'Visual Diff Tests'
<<: *push_and_pr_builds
Expand Down
5 changes: 2 additions & 3 deletions validator/WORKSPACE
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,8 @@ http_archive(

http_archive(
name = "com_google_protobuf",
sha256 = "750428a8c7f1a75a8e6027e30b46a1c2f0475205f44563589736e0f279b938c0",
strip_prefix = "protobuf-f0dc78d7e6e331b8c6bb2d5283e06aa26883ca7c",
urls = ["https://github.com/protocolbuffers/protobuf/archive/f0dc78d7e6e331b8c6bb2d5283e06aa26883ca7c.zip"],
strip_prefix = "protobuf-43e1626812c1b543e56a7bec59dc09eb18248bd2",
urls = ["https://github.com/protocolbuffers/protobuf/archive/43e1626812c1b543e56a7bec59dc09eb18248bd2.zip"],
)
load("@com_google_protobuf//:protobuf_deps.bzl", "protobuf_deps")
protobuf_deps()
Expand Down
10 changes: 7 additions & 3 deletions validator/cpp/htmlparser/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,10 @@ load("@rules_cc//cc:defs.bzl", "cc_library", "cc_test")
#
# bazel build --repo_env=CC=clang --cxxopt='-std=c++17' <build_target>

package(default_visibility = ["//visibility:public"])
package(
default_compatible_with = ["//buildenv/target:non_prod"],
default_visibility = ["//visibility:public"],
)

licenses(["notice"])

Expand Down Expand Up @@ -195,10 +198,10 @@ cc_library(
hdrs = [
"logging.h",
],
copts = ["-std=c++17"],
deps = [
":glog_polyfill",
],
copts = ["-std=c++17"],
)

# Defines token type and token structures, used during tokenization.
Expand Down Expand Up @@ -463,6 +466,7 @@ cc_test(
"tokenizer_test.cc",
],
deps = [
":atom",
":token",
":tokenizer",
"@com_google_googletest//:gtest_main",
Expand Down Expand Up @@ -551,7 +555,7 @@ cc_test(
":strings",
":testconstants",
":tokenizer",
"@com_google_googletest//:gtest_main",
"@com_google_absl//absl/flags:flag",
"@com_google_googletest//:gtest_main",
],
)
3 changes: 2 additions & 1 deletion validator/cpp/htmlparser/allocator.h
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@
// IMPORTANT: Tree like structure must not destroy the child nodes or sibling
// nodes. Allocator destroys all the objects and call its destructor, it is an
// error to invoke destructors on objects allocated by this allocator. Allocator
// is the master owner of all the objects. Client treats all objects as const
// is the primary owner of all the objects. Client treats all objects as const
// pointer as far as destruction goes.
//
// It is not possible to destroy random objects or free up the slots to be
Expand Down Expand Up @@ -174,6 +174,7 @@
#include <cstring>
#include <memory>
#include <tuple>
#include <type_traits>
#include <vector>

namespace htmlparser {
Expand Down
11 changes: 8 additions & 3 deletions validator/cpp/htmlparser/allocator_test.cc
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
#include "cpp/htmlparser/allocator.h"

#include <array>
#include <cstdint>
#include <string>
#include <vector>

#include "gtest/gtest.h"

// Memory leaks will automatically be detected by the test framework.
Expand All @@ -12,9 +17,9 @@ TEST(AllocatorTest, BasicTest) {
int32_t a;
int64_t b;
std::string c;
short d;
uint16_t d;
Data() {}
Data(int32_t a_, int64_t b_, std::string c_, short d_)
Data(int32_t a_, int64_t b_, std::string c_, uint16_t d_)
: a(a_), b(b_), c(c_), d(d_) {}
};

Expand Down Expand Up @@ -146,7 +151,7 @@ TEST(AllocatorTest, DestructorCalled) {

TEST(AllocatorTest, BitFields) {
struct HasBitFields {
short s;
uint16_t s;
char c;
int flip : 1;
int nybble : 4;
Expand Down
5 changes: 4 additions & 1 deletion validator/cpp/htmlparser/atomutil.cc
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
#include "cpp/htmlparser/atomutil.h"

#include <string>
#include <string_view>

#include "cpp/htmlparser/hash.h"

namespace htmlparser {
Expand All @@ -20,7 +23,7 @@ Atom AtomUtil::ToAtom(const std::string& s) {
table_index = (hash >> 16) & (kNamesHashTable.size() - 1);
atom_value = kNamesHashTable[table_index];
atom_len = atom_value & 0xff;
if (atom_len == s.size() && ToString(atom_value).compare(s) == 0) {
if (atom_len == s.size() && ToString(atom_value) == s) {
return CastToAtom(atom_value);
}

Expand Down
24 changes: 12 additions & 12 deletions validator/cpp/htmlparser/bin/atomgen.cc
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
#include <memory>
#include <sstream>
#include <string>
#include <string_view>
#include <utility>
#include <vector>

Expand Down Expand Up @@ -55,12 +56,12 @@ class TableBuilder {

bool Insert(const std::string& s) {
std::pair<uint32_t, uint32_t> hashes = Hash(s);
if (table_[hashes.first] == "") {
if (table_[hashes.first].empty()) {
table_[hashes.first] = s;
return true;
}

if (table_[hashes.second] == "") {
if (table_[hashes.second].empty()) {
table_[hashes.second] = s;
return true;
}
Expand Down Expand Up @@ -100,7 +101,7 @@ class TableBuilder {
std::pair<uint32_t, uint32_t> hashes = Hash(entry);
uint32_t new_location = hashes.first + hashes.second - i;

if (table_[new_location] != "" && !Push(new_location, depth + 1)) {
if (!table_[new_location].empty() && !Push(new_location, depth + 1)) {
return false;
}

Expand Down Expand Up @@ -190,17 +191,16 @@ int main(int argc, char** argv) {
// Find hash that minimizes table size.
std::unique_ptr<TableBuilder> table{nullptr};
for (int i = 0; i < 1; i++) {
if (table.get() != nullptr
&& (1 << (table->hash_num_bits() - 1)) < all_names.size()) {
if (table != nullptr &&
(1 << (table->hash_num_bits() - 1)) < all_names.size()) {
break;
}

srand(time(nullptr));
uint32_t rand_state;
uint32_t hash0 = rand_r(&rand_state) % 1000000000;
for (uint32_t k = 0; k <= 16; k++) {
if (table.get() != nullptr && k >= table->hash_num_bits())
break;
if (table != nullptr && k >= table->hash_num_bits()) break;
std::unique_ptr<TableBuilder> base(new TableBuilder());
if (base->Init(hash0, k, all_names)) {
table.reset(base.release());
Expand All @@ -209,7 +209,7 @@ int main(int argc, char** argv) {
}
}

if (table.get() == nullptr) {
if (table == nullptr) {
std::cerr << "Failed to construct string table." << std::endl;
std::cerr << all_names.size() << ": elements." << std::endl;
return EXIT_FAILURE;
Expand All @@ -224,11 +224,11 @@ int main(int argc, char** argv) {
while (changed) {
changed = false;
for (std::size_t i = 0; i < layout.size(); i++) {
if (layout[i] == "") continue;
if (layout[i].empty()) continue;

for (std::size_t j = 0; j < layout.size(); j++) {
if (i != j && layout[j] != ""
&& layout[i].find(layout[j]) != std::string::npos) {
if (i != j && !layout[j].empty() &&
layout[i].find(layout[j]) != std::string::npos) {
changed = true;
layout[j] = "";
}
Expand All @@ -244,7 +244,7 @@ int main(int argc, char** argv) {
int bestj = -1;
int bestk = 0;
for (std::size_t i = 0; i < layout.size(); i++) {
if (layout[i] == "") continue;
if (layout[i].empty()) continue;

for (std::size_t j = 0; j < layout.size(); j++) {
if (i == j) continue;
Expand Down
2 changes: 2 additions & 0 deletions validator/cpp/htmlparser/bin/casetablegen.cc
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
#include <fstream>
#include <iostream>
#include <sstream>
#include <string>
#include <utility>
#include <vector>

#include "cpp/htmlparser/defer.h"
#include "cpp/htmlparser/fileutil.h"
Expand Down
1 change: 1 addition & 0 deletions validator/cpp/htmlparser/bin/entitytablegen.cc
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
#include <fstream>
#include <iostream>
#include <sstream>
#include <string>
#include <utility>
#include <vector>

Expand Down
1 change: 1 addition & 0 deletions validator/cpp/htmlparser/bin/validatorgen.cc
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
//

#include <iostream>
#include <string>

#include "glog/logging.h"
#include "absl/flags/flag.h"
Expand Down
44 changes: 44 additions & 0 deletions validator/cpp/htmlparser/bluze.textproto
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
# proto-file: devtools/blueprint/blueprint_file.proto
# proto-message: BlueprintFile
# DO NOT EDIT! Regenerate the contents by running go/bluze after changing any BUILD file or the Blueprint.
# Override the default values in third_party.htmlparser.blueprint instead.

buildable_unit: {
name: "third_party.htmlparser"
build_pattern: "//third_party/htmlparser/..."
test_pattern: "//third_party/htmlparser/..."
test_tag_filter: "-nofastbuild"
build_tag_filter: "-nofastbuild"
enable_coverage: true
enable_presubmit: true
enable_continuous_build: true
continuous_build_email: {
build_cop_email_id: "other-3p-community-maintainers+htmlparser+buildgardener@google.com"
}
enable_release: false
}
buildable_unit: {
name: "third_party.htmlparser.opt"
test_pattern: "//third_party/htmlparser/..."
test_tag_filter: "-noopt"
build_flag: "--compilation_mode=opt"
enable_coverage: false
enable_presubmit: false
enable_continuous_build: false
continuous_build_email: {
build_cop_email_id: "other-3p-community-maintainers+htmlparser+buildgardener@google.com"
}
enable_release: false
[tap.tap_settings]: {
on_demand: true
on_demand_frequency: EVERY_4_HOURS
}
}
continuous_tests: {
name: "third_party.htmlparser"
buildable_unit_name: "third_party.htmlparser"
}
continuous_tests: {
name: "third_party.htmlparser.opt"
buildable_unit_name: "third_party.htmlparser.opt"
}
2 changes: 2 additions & 0 deletions validator/cpp/htmlparser/casetable_test.cc
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#include "cpp/htmlparser/casetable.h"

#include <string_view>

#include "gtest/gtest.h"
#include "cpp/htmlparser/strings.h"

Expand Down
9 changes: 5 additions & 4 deletions validator/cpp/htmlparser/css/amp4ads-parse-css.cc
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
#include "cpp/htmlparser/css/amp4ads-parse-css.h"

#include "absl/memory/memory.h"
#include <memory>
#include <string>
#include <vector>

#include "absl/strings/str_cat.h"
#include "absl/strings/str_join.h"
#include "cpp/htmlparser/css/parse-css.h"
#include "re2/re2.h"

using absl::make_unique;
using std::string_view;
using amp::validator::ValidationError;
using std::unique_ptr;

Expand All @@ -18,7 +19,7 @@ namespace {
unique_ptr<ErrorToken> CreateParseErrorTokenAt(
const Token& position_token, ValidationError::Code code,
const std::vector<std::string>& params) {
auto token = make_unique<ErrorToken>(code, params);
auto token = std::make_unique<ErrorToken>(code, params);
position_token.CopyStartPositionTo(token.get());
return token;
}
Expand Down
2 changes: 2 additions & 0 deletions validator/cpp/htmlparser/css/parse-css-urls.cc
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
#include "cpp/htmlparser/css/parse-css-urls.h"

#include <memory>
#include <string>
#include <utility>

#include "absl/algorithm/container.h"
#include "absl/memory/memory.h"
Expand Down
3 changes: 2 additions & 1 deletion validator/cpp/htmlparser/css/parse-css-urls_test.cc
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
#include "cpp/htmlparser/css/parse-css-urls.h"

#include <ostream>
#include <string>
#include <vector>

#include <gmock/gmock.h>
#include "gtest/gtest.h"
#include "absl/strings/str_cat.h"
#include "cpp/htmlparser/strings.h"

using testing::Eq;
using testing::Pointwise;

namespace htmlparser::css::url {
Expand Down
5 changes: 5 additions & 0 deletions validator/cpp/htmlparser/css/parse-css.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@

#include <deque>
#include <memory>
#include <sstream>
#include <string>
#include <string_view>
#include <utility>
#include <vector>

#include "absl/algorithm/container.h"
#include "absl/memory/memory.h"
Expand Down
4 changes: 4 additions & 0 deletions validator/cpp/htmlparser/css/parse-css_test.cc
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
#include "cpp/htmlparser/css/parse-css.h"

#include <algorithm>
#include <memory>
#include <string>
#include <string_view>
#include <utility>
#include <vector>

#include <gmock/gmock.h>
Expand Down
Loading
Loading