From 1095179374987771732009ac9eb702fc783eb025 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?K=C3=A9vin=20Commaille?= <76261501+zecakeh@users.noreply.github.com> Date: Tue, 23 Apr 2024 17:30:21 +0200 Subject: [PATCH] Upgrade version of Hugo used to build the spec in CI (#1794) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Upgrade version of Hugo used to build the spec in CI Signed-off-by: Kévin Commaille * Escape HTML manually in property-type partial The behavior of `delimit` changed, so Hugo doesn't recognize "safe" HTML passed to it anymore, so it escapes nested HTML links. To fix that we escape the schema data manually and consider the output of the partial as "safe". Signed-off-by: Kévin Commaille * Add changelog Signed-off-by: Kévin Commaille --------- Signed-off-by: Kévin Commaille --- .github/workflows/main.yml | 3 ++- changelogs/internal/newsfragments/1794.clarification | 1 + layouts/partials/openapi/render-object-table.html | 12 ++++++------ 3 files changed, 9 insertions(+), 7 deletions(-) create mode 100644 changelogs/internal/newsfragments/1794.clarification diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 3288b42a..de66484d 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -268,7 +268,8 @@ jobs: - name: "➕ Setup Hugo" uses: peaceiris/actions-hugo@16361eb4acea8698b220b76c0d4e84e1fd22c61d with: - hugo-version: '0.113.0' + # Cannot build the spec with Hugo 0.125.0 because of https://github.com/google/docsy/issues/1930 + hugo-version: '0.124.1' extended: true - name: "📥 Source checkout" uses: actions/checkout@v4 diff --git a/changelogs/internal/newsfragments/1794.clarification b/changelogs/internal/newsfragments/1794.clarification new file mode 100644 index 00000000..3c38016a --- /dev/null +++ b/changelogs/internal/newsfragments/1794.clarification @@ -0,0 +1 @@ +Update the version of Hugo used to render the spec to v0.124.1. diff --git a/layouts/partials/openapi/render-object-table.html b/layouts/partials/openapi/render-object-table.html index 030978b1..6faa21d9 100644 --- a/layouts/partials/openapi/render-object-table.html +++ b/layouts/partials/openapi/render-object-table.html @@ -46,7 +46,7 @@ {{ $property_name }} - {{ partial "partials/property-type" $property }} + {{ partial "partials/property-type" $property | safeHTML }} {{ partial "partials/property-description" (dict "property" $property "required" $required) }} @@ -67,7 +67,7 @@ {{ $property := . }} - {{ partial "partials/property-type" $property }} + {{ partial "partials/property-type" $property | safeHTML }} {{ partial "partials/property-description" (dict "property" $property) }} @@ -128,14 +128,14 @@ {{ end }} {{ else }} {{ range .type }} - {{ $types = $types | append . }} + {{ $types = $types | append (htmlEscape .) }} {{ end }} {{ end }} {{ $type = delimit $types "|" }} {{ else }} {{/* A simple type like string or boolean */}} - {{ $type = .type }} + {{ $type = (htmlEscape .type) }} {{ end }} {{ return $type }} @@ -165,9 +165,9 @@ If the property has a `title`, use that rather than `type`. This means we can write things like `EventFilter` rather than `object`. */}} - {{ $type = .title }} + {{ $type = .title | htmlEscape }} {{ if .anchor }} - {{ $type = printf "%s" (htmlEscape .anchor) (htmlEscape $type) | safeHTML }} + {{ $type = printf "%s" (htmlEscape .anchor) $type }} {{ end }} {{ else if reflect.IsMap .additionalProperties }} {{/*