From 91b435c63ff9fd86db27844c5bf265a7dd63d8d0 Mon Sep 17 00:00:00 2001 From: Forbes Lindesay Date: Fri, 13 Mar 2026 15:04:57 +0000 Subject: [PATCH] fix: doctype option was not validated correctly --- .github/workflows/rollingversions-canary.yml | 40 -------------------- .github/workflows/rollingversions.yml | 24 +++++++++++- packages/pug-code-gen/index.js | 8 ++-- 3 files changed, 27 insertions(+), 45 deletions(-) delete mode 100644 .github/workflows/rollingversions-canary.yml diff --git a/.github/workflows/rollingversions-canary.yml b/.github/workflows/rollingversions-canary.yml deleted file mode 100644 index 3fe8e91b1..000000000 --- a/.github/workflows/rollingversions-canary.yml +++ /dev/null @@ -1,40 +0,0 @@ -name: Publish Canary - -on: - push: - branches: - - master - -jobs: - test: - runs-on: ubuntu-latest - - strategy: - matrix: - node-version: [10.x, 12.x, 14.x] - - steps: - - uses: actions/checkout@v2 - - name: Use Node.js ${{ matrix.node-version }} - uses: actions/setup-node@v1 - with: - node-version: ${{ matrix.node-version }} - - run: yarn install --frozen-lockfile - - run: yarn prettier:check - - run: yarn test - - publish-canary: - runs-on: ubuntu-latest - needs: test - steps: - - uses: actions/checkout@v2 - - uses: actions/setup-node@v1 - with: - node-version: 12.x - registry-url: 'https://registry.npmjs.org' - - run: yarn install --frozen-lockfile - - run: yarn build - - run: npx rollingversions publish --canary $GITHUB_RUN_NUMBER - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} diff --git a/.github/workflows/rollingversions.yml b/.github/workflows/rollingversions.yml index 441206aa5..145e647fb 100644 --- a/.github/workflows/rollingversions.yml +++ b/.github/workflows/rollingversions.yml @@ -1,5 +1,8 @@ name: Release on: + push: + branches: + - master repository_dispatch: types: [rollingversions_publish_approved] @@ -21,18 +24,35 @@ jobs: - run: yarn prettier:check - run: yarn test + + publish-canary: + runs-on: ubuntu-latest + if: ${{ github.event_name == 'push' }} + needs: test + steps: + - uses: actions/checkout@v2 + - uses: actions/setup-node@v1 + with: + node-version: 24.x + registry-url: 'https://registry.npmjs.org' + - run: yarn install --frozen-lockfile + - run: yarn build + - run: npx rollingversions publish --canary $GITHUB_RUN_NUMBER + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + publish: runs-on: ubuntu-latest + if: ${{ github.event_name == 'repository_dispatch' }} needs: test steps: - uses: actions/checkout@v2 - uses: actions/setup-node@v1 with: - node-version: 12.x + node-version: 24.x registry-url: 'https://registry.npmjs.org' - run: yarn install --frozen-lockfile - run: yarn build - run: npx rollingversions publish env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} diff --git a/packages/pug-code-gen/index.js b/packages/pug-code-gen/index.js index 3e6bf3b27..738b8f7cf 100644 --- a/packages/pug-code-gen/index.js +++ b/packages/pug-code-gen/index.js @@ -72,8 +72,8 @@ function Compiler(node, options) { ); } if ( - this.doctype && - (this.doctype.includes('<') || this.doctype.includes('>')) + this.options.doctype && + (this.options.doctype.includes('<') || this.options.doctype.includes('>')) ) { throw new Error('Doctype can not contain "<" or ">"'); } @@ -209,7 +209,9 @@ Compiler.prototype = { */ setDoctype: function(name) { - this.doctype = doctypes[name.toLowerCase()] || ''; + this.doctype = doctypes.hasOwnProperty(name.toLowerCase()) + ? doctypes[name.toLowerCase()] + : ''; this.terse = this.doctype.toLowerCase() == ''; this.xml = 0 == this.doctype.indexOf('