fix: the definitions migration keeps and logs every url item
Migration 202610280002 converts the Phase 17 url items through models.ConvertLegacyItems: a relative path gets its leading slash, spaces and the bytes " < > \ are percent-encoded, and a malformed item no longer drops the whole definition. Each url item that cannot be copied is logged at warn level with its label, value and reason.
This commit is contained in:
@@ -349,7 +349,11 @@ func TestMigrateDefinitions(t *testing.T) {
|
||||
`{"type":"url","url":"/o-nas"},` +
|
||||
`{"type":"url","url":"javascript:alert(1)"},` +
|
||||
`{"type":"url","url":"/"},` +
|
||||
`{"type":"url","url":"https://www.example.test/kontakt"}]`
|
||||
`{"type":"url","url":"https://www.example.test/kontakt"},` +
|
||||
`{"type":"url","url":"kontakt-pl"},` +
|
||||
`{"type":"url","url":"/blog/zażółć gęślą"},` +
|
||||
`{"type":"url","url":"https://www.example.test/x?a=1&b=2"},` +
|
||||
`{"type":"url","url":{"bad":true}}]`
|
||||
for _, stmt := range []struct {
|
||||
sql string
|
||||
args []any
|
||||
@@ -369,7 +373,10 @@ func TestMigrateDefinitions(t *testing.T) {
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if got := extraURLs(s.Extra()); got != "/ /o-nas https://www.example.test/kontakt" {
|
||||
// L2 WR-04: one malformed item no longer drops the definition, a
|
||||
// relative path gets its slash and a space is percent-encoded; the &
|
||||
// URL and javascript: are dropped (and logged).
|
||||
if got := extraURLs(s.Extra()); got != "/ /o-nas https://www.example.test/kontakt /kontakt-pl /blog/zażółć%20gęślą" {
|
||||
t.Fatalf("extra_urls = %q", got)
|
||||
}
|
||||
for _, e := range s.Extra() {
|
||||
|
||||
Reference in New Issue
Block a user