Skip to content

Commit 5bee330

Browse files
authored
Merge branch 'main' into dependabot/go_modules/golang.org/x/net-0.23.0
2 parents 9198ac5 + 530852a commit 5bee330

File tree

19 files changed

+551
-105
lines changed

19 files changed

+551
-105
lines changed

.github/workflows/golang-lint.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,9 @@ jobs:
1414
runs-on: ubuntu-latest
1515
steps:
1616
- uses: actions/checkout@v3
17-
- uses: actions/setup-go@v3
17+
- uses: actions/setup-go@v5
1818
with:
19-
go-version: "1.20"
19+
go-version: "1.23"
2020
check-latest: true
2121

2222
- name: golangci-lint

ast.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -177,6 +177,7 @@ type nodeElement struct {
177177
startTagNodes []node
178178
children []node
179179
pos span
180+
selfClosing bool
180181
}
181182

182183
func (e nodeElement) Pos() span { return e.pos }

flake.lock

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

flake.nix

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
description = "Pushup is a new web framework for Go";
33

4-
inputs.nixpkgs.url = "github:NixOS/nixpkgs/nixos-23.11";
4+
inputs.nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
55

66
outputs = { self, nixpkgs }:
77
let
@@ -46,25 +46,30 @@
4646
};
4747

4848
in {
49-
default = pkgs.buildGoModule rec {
49+
# https://github.com/NixOS/nixpkgs/blob/master/pkgs/build-support/go/module.nix
50+
default = pkgs.buildGoModule.override {
51+
go = pkgs.go_1_23;
52+
} rec {
5053
inherit pname version src vendorHash subPackages CGO_ENABLED meta;
5154
};
5255

53-
withGo = pkgs.buildGoModule rec {
56+
withGo = pkgs.buildGoModule.override {
57+
go = pkgs.go_1_23;
58+
} rec {
5459
inherit pname version src vendorHash subPackages CGO_ENABLED meta;
5560
nativeBuildInputs = with pkgs; [ makeWrapper ];
5661
allowGoReference = true;
5762
postInstall = ''
5863
wrapProgram $out/bin/${pname} --prefix PATH : ${
59-
pkgs.lib.makeBinPath (with pkgs; [ go ])
64+
pkgs.lib.makeBinPath (with pkgs; [ go_1_23 ])
6065
}
6166
'';
6267
};
6368
});
6469

6570
devShells = forEachSystem ({ pkgs, ... }: {
6671
default =
67-
pkgs.mkShell { buildInputs = with pkgs; [ go_1_20 gotools gopls ]; };
72+
pkgs.mkShell { buildInputs = with pkgs; [ go_1_23 gotools gopls ]; };
6873
});
6974
};
7075
}

go.mod

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
module github.com/adhocteam/pushup
22

3-
go 1.20
3+
go 1.23
44

55
require (
66
github.com/fsnotify/fsnotify v1.5.4
77
github.com/google/go-cmp v0.5.8
8-
golang.org/x/mod v0.7.0
9-
golang.org/x/net v0.23.0
8+
golang.org/x/mod v0.21.0
9+
golang.org/x/net v0.17.0
1010
golang.org/x/sync v0.1.0
1111
)
1212

go.sum

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ golang.org/x/mod v0.7.0 h1:LapD9S96VoQRhi/GrNTqeBJFrUjs5UHCAtTlgwA5oZA=
66
golang.org/x/mod v0.7.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs=
77
golang.org/x/net v0.23.0 h1:7EYJ93RZ9vYSZAIb2x3lnuvqO5zneoD6IvWjuhfxjTs=
88
golang.org/x/net v0.23.0/go.mod h1:JKghWKKOSdJwpW2GEx0Ja7fmaKnMsbu+MWVZTokSYmg=
9+
golang.org/x/mod v0.21.0 h1:vvrHzRwRfVKSiLrG+d4FMl/Qi4ukBCE6kZlTUkDYRT0=
10+
golang.org/x/mod v0.21.0/go.mod h1:6SkKJ3Xj0I0BrPOZoBy3bdMptDDU9oJrpohJ3eWZ1fY=
911
golang.org/x/sync v0.1.0 h1:wsuoTGHzEhffawBOhz5CYhcrV4IdKZbEyZjBMuTp12o=
1012
golang.org/x/sync v0.1.0/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
1113
golang.org/x/sys v0.0.0-20220412211240-33da011f77ad/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=

main.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -282,7 +282,7 @@ func setBuildFlags(flags *flag.FlagSet, b *buildCmd) {
282282
flags.StringVar(&b.outDir, "out-dir", "./build", "path to output build directory. Defaults to ./build")
283283
flags.StringVar(&b.outFile, "out-file", "", "path to output application binary. Defaults to ./build/bin/projectName")
284284
flags.BoolVar(&b.embedSource, "embed-source", true, "embed the source .up files in executable")
285-
flags.Var(&b.pages, "page", "path to a Pushup page. mulitple can be given")
285+
flags.Var(&b.pages, "page", "path to a Pushup page. multiple can be given")
286286
flags.BoolVar(&b.verbose, "verbose", false, "output verbose information")
287287
}
288288

parser.go

Lines changed: 45 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -420,23 +420,35 @@ func newTag(tagname []byte, attrs []*attr) tag {
420420
return tag{name: string(tagname), attrs: attrs}
421421
}
422422

423-
func (p *htmlParser) match(typ html.TokenType) bool {
424-
return p.toktyp == typ
423+
func (p *htmlParser) match(types ...html.TokenType) bool {
424+
for _, typ := range types {
425+
if p.toktyp == typ {
426+
return true
427+
}
428+
}
429+
return false
425430
}
426431

427432
func (p *htmlParser) parseElement() node {
428433
var result *nodeElement
429434

430-
// FIXME(paulsmith): handle self-closing elements
431-
if !p.match(html.StartTagToken) {
432-
p.errorf("expected an HTML element start tag, got %s", p.toktyp)
435+
if !p.match(html.StartTagToken, html.SelfClosingTagToken) {
436+
p.errorf("expected an HTML element start or self-closing tag, got %s", p.toktyp)
433437
}
434438

435439
result = new(nodeElement)
436440
result.tag = newTag(p.tagname, p.attrs)
437441
result.pos.start = p.parser.offset - len(p.raw)
438442
result.pos.end = p.parser.offset
443+
if p.match(html.SelfClosingTagToken) {
444+
result.selfClosing = true
445+
}
439446
result.startTagNodes = p.parseStartTag()
447+
448+
if isVoidElement(result.tag.name) {
449+
return result
450+
}
451+
440452
p.advance()
441453

442454
result.children = p.parseChildren()
@@ -462,31 +474,28 @@ func (p *htmlParser) parseChildren() []node {
462474
var elemStack []*nodeElement
463475
loop:
464476
for {
465-
switch p.toktyp {
477+
switch tt := p.toktyp; tt {
466478
case html.ErrorToken:
467479
if p.err == io.EOF {
468480
break loop
469481
} else {
470482
p.errorf("HTML tokenizer: %w", p.err)
471483
}
472-
case html.SelfClosingTagToken:
473-
elem := new(nodeElement)
474-
elem.tag = newTag(p.tagname, p.attrs)
475-
elem.pos.start = p.parser.offset - len(p.raw)
476-
elem.pos.end = p.parser.offset
477-
elem.startTagNodes = p.parseStartTag()
478-
p.advance()
479-
result = append(result, elem)
480-
case html.StartTagToken:
484+
case html.StartTagToken, html.SelfClosingTagToken:
481485
elem := new(nodeElement)
482486
elem.tag = newTag(p.tagname, p.attrs)
483487
elem.pos.start = p.parser.offset - len(p.raw)
484488
elem.pos.end = p.parser.offset
485489
elem.startTagNodes = p.parseStartTag()
490+
if tt == html.SelfClosingTagToken {
491+
elem.selfClosing = true
492+
}
486493
p.advance()
487-
elem.children = p.parseChildren()
494+
if !isVoidElement(elem.tag.name) {
495+
elem.children = p.parseChildren()
496+
elemStack = append(elemStack, elem)
497+
}
488498
result = append(result, elem)
489-
elemStack = append(elemStack, elem)
490499
case html.EndTagToken:
491500
if len(elemStack) == 0 {
492501
return result
@@ -534,6 +543,25 @@ loop:
534543
return result
535544
}
536545

546+
func isVoidElement(tagname string) bool {
547+
// Per spec: https://html.spec.whatwg.org/multipage/syntax.html#void-elements
548+
voidElements := map[string]bool{"area": true,
549+
"base": true,
550+
"br": true,
551+
"col": true,
552+
"embed": true,
553+
"hr": true,
554+
"img": true,
555+
"input": true,
556+
"link": true,
557+
"meta": true,
558+
"source": true,
559+
"track": true,
560+
"wbr": true,
561+
}
562+
return voidElements[tagname]
563+
}
564+
537565
type Optional[T any] struct {
538566
value *T
539567
}

parser_test.go

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -405,6 +405,27 @@ func TestParse(t *testing.T) {
405405
},
406406
},
407407
},
408+
{
409+
`^if true { <br/> }`,
410+
&syntaxTree{
411+
nodes: []node{
412+
&nodeIf{
413+
cond: &nodeGoStrExpr{expr: "true", pos: span{start: 4, end: 8}},
414+
then: &nodeBlock{
415+
nodes: []node{
416+
&nodeLiteral{str: " ", pos: span{10, 11}},
417+
&nodeElement{
418+
tag: tag{name: "br"},
419+
startTagNodes: []node{&nodeLiteral{str: "<br/>", pos: span{start: 11, end: 16}}},
420+
pos: span{11, 16},
421+
selfClosing: true,
422+
},
423+
},
424+
},
425+
},
426+
},
427+
},
428+
},
408429
}
409430
opts := cmp.AllowUnexported(unexported...)
410431
for _, test := range tests {
@@ -450,7 +471,7 @@ func TestParseSyntaxErrors(t *testing.T) {
450471
{
451472
`^if true {
452473
<illegal />
453-
}`, 2, 13,
474+
}`, 3, 2,
454475
},
455476
// FIXME(paulsmith): add more syntax errors
456477
}

vendor/golang.org/x/mod/LICENSE

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

vendor/golang.org/x/mod/internal/lazyregexp/lazyre.go

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

vendor/golang.org/x/mod/modfile/print.go

Lines changed: 12 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

vendor/golang.org/x/mod/modfile/read.go

Lines changed: 6 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)