nebius/SWE-rebench-V2-PRs huggingface dataset:
Repository: Evertras/bubble-table
Pull request #131 (2023-02-13 07:43:40)

fix: filter not works when using StyledCell
Before:

If I using filter on StyledCell, it will show nothing.

After fixing:

filter works.

alswl: The golang-lint error seems related to https://github.com/golangci/golangci-lint/issues/2374
Evertras: Seems reasonable, I think the linting will have to be fixed in the pipeline.  Thanks for the contribution!

Patch:
diff --git a/table/filter.go b/table/filter.go
index bde8eb2..e8274a8 100644
--- a/table/filter.go
+++ b/table/filter.go
@@ -41,16 +41,19 @@ func isRowMatched(columns []Column, row Row, filter string) bool {
 			continue
 		}
 
+		target := ""
 		switch dataV := data.(type) {
 		case string:
-			if strings.Contains(strings.ToLower(dataV), strings.ToLower(filter)) {
-				return true
-			}
+			target = dataV
 
 		case fmt.Stringer:
-			if strings.Contains(strings.ToLower(dataV.String()), strings.ToLower(filter)) {
-				return true
-			}
+			target = dataV.String()
+
+		case StyledCell:
+			target = dataV.Data.(string)
+		}
+		if strings.Contains(strings.ToLower(target), strings.ToLower(filter)) {
+			return true
 		}
 	}
 


Test patch:
diff --git a/table/filter_test.go b/table/filter_test.go
index 3c10c88..ac4d758 100644
--- a/table/filter_test.go
+++ b/table/filter_test.go
@@ -1,6 +1,7 @@
 package table
 
 import (
+	"github.com/charmbracelet/lipgloss"
 	"testing"
 	"time"
 
@@ -67,6 +68,24 @@ func TestIsRowMatched(t *testing.T) {
 	))
 }
 
+func TestIsRowMatchedForStyled(t *testing.T) {
+	columns := []Column{
+		NewColumn("title", "title", 10).WithFiltered(true),
+		NewColumn("description", "description", 10)}
+
+	assert.True(t, isRowMatched(columns,
+		NewRow(RowData{
+			"title":       "AAA",
+			"description": "",
+		}), "AA"))
+
+	assert.True(t, isRowMatched(columns,
+		NewRow(RowData{
+			"title":       NewStyledCell("AAA", lipgloss.NewStyle()),
+			"description": "",
+		}), "AA"))
+}
+
 func TestGetFilteredRowsNoColumnFiltered(t *testing.T) {
 	columns := []Column{NewColumn("title", "title", 10)}
 	rows := []Row{
Repository: Evertras/bubble-table
Pull request #143 (2023-03-17 12:53:13)

Go to first page on filter API change, same as built-in filter
#136 

We were going back to the first page when our built-in filter changed, but not when the provided filter APIs changed.  This makes the behavior consistent across all filtering options.


Patch:
diff --git a/table/options.go b/table/options.go
index 69a1d5e..f4bc120 100644
--- a/table/options.go
+++ b/table/options.go
@@ -279,6 +279,10 @@ func (m Model) WithColumns(columns []Column) Model {
 // filtering rather than using the built-in default.  This allows for external
 // text input controls to be used.
 func (m Model) WithFilterInput(input textinput.Model) Model {
+	if m.filterTextInput.Value() != input.Value() {
+		m.pageFirst()
+	}
+
 	m.filterTextInput = input
 
 	return m
@@ -288,6 +292,10 @@ func (m Model) WithFilterInput(input textinput.Model) Model {
 // applying it as if the user had typed it in.  Useful for external filter inputs
 // that are not necessarily a text input.
 func (m Model) WithFilterInputValue(value string) Model {
+	if m.filterTextInput.Value() != value {
+		m.pageFirst()
+	}
+
 	m.filterTextInput.SetValue(value)
 	m.filterTextInput.Blur()
 


Test patch:
diff --git a/table/filter_test.go b/table/filter_test.go
index 632be71..acf0bb2 100644
--- a/table/filter_test.go
+++ b/table/filter_test.go
@@ -242,10 +242,15 @@ func TestFilterWithExternalTextInput(t *testing.T) {
 		// Empty
 		NewRow(RowData{}),
 	}
-	model := New(columns).WithRows(rows).Filtered(true)
+
+	// Page size 1 to test scrolling back if input changes
+	model := New(columns).WithRows(rows).Filtered(true).WithPageSize(1)
+	model.pageDown()
+	assert.Equal(t, 2, model.CurrentPage(), "Should start on second page for test")
 	input := textinput.New()
 	input.SetValue("AaA")
 	model = model.WithFilterInput(input)
+	assert.Equal(t, 1, model.CurrentPage(), "Did not go back to first page")
 
 	filteredRows := model.getFilteredRows(rows)
 
@@ -266,9 +271,15 @@ func TestFilterWithSetValue(t *testing.T) {
 		// Empty
 		NewRow(RowData{}),
 	}
-	model := New(columns).WithRows(rows).Filtered(true)
+
+	// Page size 1 to make sure we scroll back correctly
+	model := New(columns).WithRows(rows).Filtered(true).WithPageSize(1)
+	model.pageDown()
+	assert.Equal(t, 2, model.CurrentPage(), "Should start on second page for test")
 	model = model.WithFilterInputValue("AaA")
 
+	assert.Equal(t, 1, model.CurrentPage(), "Did not go back to first page")
+
 	filteredRows := model.getFilteredRows(rows)
 	assert.Len(t, filteredRows, 1)
Repository: Evertras/bubble-table
Pull request #152 (2023-10-08 22:56:38)

Add `Model.GetFooterVisibility` function
This is analog to the `GetHeaderVisibility` function. Note that it only reports if the footer should be visible, but if it has no contents it won't be rendered.


Patch:
diff --git a/table/query.go b/table/query.go
index 669915e..79da50f 100644
--- a/table/query.go
+++ b/table/query.go
@@ -80,6 +80,14 @@ func (m *Model) GetHeaderVisibility() bool {
 	return m.headerVisible
 }
 
+// GetFooterVisibility returns true if the footer has been set to
+// visible (default) or false if the footer has been set to hidden.
+// Note that even if the footer is visible it will only be rendered if
+// it has contents.
+func (m *Model) GetFooterVisibility() bool {
+	return m.footerVisible
+}
+
 // GetPaginationWrapping returns true if pagination wrapping is enabled, or false
 // if disabled.  If disabled, navigating through pages will stop at the first
 // and last pages.


Test patch:
diff --git a/table/query_test.go b/table/query_test.go
index 123948b..8de73fe 100644
--- a/table/query_test.go
+++ b/table/query_test.go
@@ -171,6 +171,16 @@ func TestGetHeaderVisibility(t *testing.T) {
 	assert.False(t, model.GetHeaderVisibility(), "Header was not set to hidden")
 }
 
+func TestGetFooterVisibility(t *testing.T) {
+	model := New([]Column{})
+
+	assert.True(t, model.GetFooterVisibility(), "Footer should be visible by default")
+
+	model = model.WithFooterVisibility(false)
+
+	assert.False(t, model.GetFooterVisibility(), "Footer was not set to hidden")
+}
+
 func TestGetPaginationWrapping(t *testing.T) {
 	model := New([]Column{})
Repository: Eyevinn/mp4ff
Pull request #204 (2023-01-18 15:58:29)

feat: RemoveBoxDecoder makes it possible to make a specific box unknown
Add new function RemoveBoxDecoder that turns off decoding of a specific box type by deleting its mapping.
This makes it possible to get around problems with certain uninteresting box types.
A test with a malformed `meta` box was added to exemplify how this can be used.


Patch:
diff --git a/mp4/box.go b/mp4/box.go
index 2567cf8..fdb58dd 100644
--- a/mp4/box.go
+++ b/mp4/box.go
@@ -135,6 +135,22 @@ func init() {
 	}
 }
 
+// RemoveBoxDecoder removes the decode of boxType. It will be treated as unknown instead.
+//
+// This is a global change, so use with care.
+func RemoveBoxDecoder(boxType string) {
+	delete(decoders, boxType)
+	delete(decodersSR, boxType)
+}
+
+// SetBoxDecoder sets decoder functions for a specific boxType.
+//
+// This is a global change, so use with care.
+func SetBoxDecoder(boxType string, dec BoxDecoder, decSR BoxDecoderSR) {
+	decoders[boxType] = dec
+	decodersSR[boxType] = decSR
+}
+
 // BoxHeader - 8 or 16 bytes depending on size
 type BoxHeader struct {
 	Name   string


Test patch:
diff --git a/mp4/box_test.go b/mp4/box_test.go
new file mode 100644
index 0000000..9b64f9e
--- /dev/null
+++ b/mp4/box_test.go
@@ -0,0 +1,52 @@
+package mp4
+
+import (
+	"bytes"
+	"encoding/hex"
+	"testing"
+
+	"github.com/Eyevinn/mp4ff/bits"
+)
+
+// TestBadBoxAndRemoveBoxDecoder checks that we can avoid decoder error by removing a BoxDecode.
+//
+// The box is then interpreted as an UnknownBox and its data is not further processed with decoded.
+func TestBadBoxAndRemoveBoxDecoder(t *testing.T) {
+	badMetaBox := (`000000416d6574610000002168646c7200000000000000006d64746100000000` +
+		`000000000000000000000000106b657973000000000000000000000008696c7374`)
+	data, err := hex.DecodeString(badMetaBox)
+	if err != nil {
+		t.Error(err)
+	}
+	sr := bits.NewFixedSliceReader(data)
+	_, err = DecodeBoxSR(0, sr)
+	if err == nil {
+		t.Errorf("reading bad meta box should have failed")
+	}
+	sr = bits.NewFixedSliceReader(data)
+	RemoveBoxDecoder("meta")
+	defer SetBoxDecoder("meta", DecodeMeta, DecodeMetaSR)
+	box, err := DecodeBoxSR(0, sr)
+	if err != nil {
+		t.Error(err)
+	}
+	_, ok := box.(*MetaBox)
+	if ok {
+		t.Errorf("box should not be MetaBox")
+	}
+	unknown, ok := box.(*UnknownBox)
+	if !ok {
+		t.Errorf("box should be unknown")
+	}
+	if unknown.Type() != "meta" {
+		t.Errorf("unknown type %q instead of meta", unknown.Type())
+	}
+	b := bytes.Buffer{}
+	err = unknown.Encode(&b)
+	if err != nil {
+		t.Error(err)
+	}
+	if !bytes.Equal(data, b.Bytes()) {
+		t.Errorf("written unknown differs")
+	}
+}
Repository: Eyevinn/mp4ff
Pull request #324 (2024-02-12 09:29:13)

feat: InitSegment.TweakSingleTrakLive to tweak init segments
Live streams should not have an mehd box in the init segment.
This PR adds a method to remove such a box if present.

Replaces #323 


Patch:
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 83e67de..3e8cafe 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -7,7 +7,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
 
 ## [Unreleased]
 
-- Nothing yet
+### Added
+
+- InitSegment.TweakSingleTrakLive changes an init segment to fit live streaming
 
 ## [0.42.0] - 2024-01-26
 
diff --git a/mp4/initsegment.go b/mp4/initsegment.go
index beb41da..0d06bb1 100644
--- a/mp4/initsegment.go
+++ b/mp4/initsegment.go
@@ -248,6 +248,29 @@ func (s *InitSegment) GetMediaType() string {
 	}
 }
 
+// TweakSingleTrakLive assures that there is only one track and removes any mehd box.
+func (s *InitSegment) TweakSingleTrakLive() error {
+	if len(s.Moov.Traks) != 1 {
+		return fmt.Errorf("only one track allowed for live")
+	}
+	mvex := s.Moov.Mvex
+	if mvex == nil {
+		return fmt.Errorf("no mvex box found")
+
+	}
+	mehd := mvex.Mehd
+	if mehd != nil {
+		for i, c := range mvex.Children {
+			if c == mehd {
+				mvex.Children = append(mvex.Children[:i], mvex.Children[i+1:]...)
+				mvex.Mehd = nil
+				break
+			}
+		}
+	}
+	return nil
+}
+
 // SetAACDescriptor - Modify a TrakBox by adding AAC SampleDescriptor
 // objType is one of AAClc, HEAACv1, HEAACv2
 // For HEAAC, the samplingFrequency is the base frequency (normally 24000)


Test patch:
diff --git a/mp4/initsegment_test.go b/mp4/initsegment_test.go
index 13c8aaf..5da7f87 100644
--- a/mp4/initsegment_test.go
+++ b/mp4/initsegment_test.go
@@ -211,3 +211,37 @@ func TestGenerateInitSegment(t *testing.T) {
 		t.Errorf("Generated init segment different from %s", goldenAssetPath)
 	}
 }
+
+func TestInitTweakSingleTrakLive(t *testing.T) {
+	// Check that mehd box is removed and that multiple tracks is not allowed.
+	goldenAssetPath := "testdata/golden_init_video.mp4"
+	r, err := os.Open(goldenAssetPath)
+	if err != nil {
+		t.Error(err)
+	}
+	f, err := DecodeFile(r)
+	if err != nil {
+		t.Error(err)
+	}
+	moov := f.Init.Moov
+	mvex := moov.Mvex
+	mehd := MehdBox{
+		FragmentDuration: 1000,
+	}
+	mvex.AddChild(&mehd)
+	err = f.Init.TweakSingleTrakLive()
+	if err != nil {
+		t.Error(err)
+	}
+	if mvex.Mehd != nil {
+		t.Errorf("Mehd not removed")
+	}
+	f.Init.AddEmptyTrack(180000, "video", "und")
+	err = f.Init.TweakSingleTrakLive()
+	wantedErrMsg := "only one track allowed for live"
+	if err == nil {
+		t.Errorf("Did not get error")
+	} else if err.Error() != wantedErrMsg {
+		t.Errorf(`Did not get error %q but %q"`, wantedErrMsg, err)
+	}
+}
Repository: Eyevinn/mp4ff
Pull request #330 (2024-02-22 15:38:16)

fix: pssh box extraction in DecryptInit
Solves #329


Patch:
diff --git a/mp4/crypto.go b/mp4/crypto.go
index ce33bbd..1515f92 100644
--- a/mp4/crypto.go
+++ b/mp4/crypto.go
@@ -526,7 +526,7 @@ func DecryptInit(init *InitSegment) (DecryptInfo, error) {
 			}
 		}
 	}
-	_ = moov.RemovePsshs()
+	di.Psshs = moov.RemovePsshs()
 	return di, nil
 }
 


Test patch:
diff --git a/mp4/crypto_test.go b/mp4/crypto_test.go
index 15dec1d..11fe2e8 100644
--- a/mp4/crypto_test.go
+++ b/mp4/crypto_test.go
@@ -189,3 +189,25 @@ func TestEncryptDecryptAVC(t *testing.T) {
 		}
 	}
 }
+
+func TestDecryptInit(t *testing.T) {
+	encFile := "testdata/prog_8s_enc_dashinit.mp4"
+	mp4f, err := ReadMP4File(encFile)
+	if err != nil {
+		t.Error(err)
+	}
+	init := mp4f.Init
+	decInfo, err := DecryptInit(init)
+	if err != nil {
+		t.Error(err)
+	}
+	if len(decInfo.Psshs) != 1 {
+		t.Error("Pssh not extracted")
+	}
+	for _, tr := range decInfo.TrackInfos {
+		schemeType := tr.Sinf.Schm.SchemeType
+		if schemeType != "cenc" {
+			t.Errorf("Expected cenc, got %s", schemeType)
+		}
+	}
+}
Repository: Eyevinn/mp4ff
Pull request #394 (2024-12-16 21:25:03)

fix:  don't enforce minimal esds size
Handle case when esds box is shorter because (the mandatory) SLConfig descriptor is not present.

Solves #393.


Patch:
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 2b5017d..7c8a7cc 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -17,6 +17,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
 
 - mp4.SetUUID() can take base64 string as well as hex-encoded.
 
+### Fixed
+
+- support short ESDS without SLConfig descriptor (issue #393)
+
 ## [0.47.0] - 2024-11-12
 
 ### Changed
diff --git a/mp4/descriptors.go b/mp4/descriptors.go
index bf42bd3..83f6213 100644
--- a/mp4/descriptors.go
+++ b/mp4/descriptors.go
@@ -20,8 +20,6 @@ const (
 	DecoderConfigDescrTag = 4
 	DecSpecificInfoTag    = 5
 	SLConfigDescrTag      = 6
-
-	minimalEsDescrSize = 25
 )
 
 func TagType(tag byte) string {
diff --git a/mp4/esds.go b/mp4/esds.go
index d1eced5..eea7c6d 100644
--- a/mp4/esds.go
+++ b/mp4/esds.go
@@ -42,9 +42,6 @@ func DecodeEsdsSR(hdr BoxHeader, startPos uint64, sr bits.SliceReader) (Box, err
 		Version: version,
 		Flags:   versionAndFlags & flagsMask,
 	}
-	if hdr.Size < 12+minimalEsDescrSize {
-		return nil, fmt.Errorf("too few bytes in esds box")
-	}
 	descSize := uint32(hdr.Size - 12)
 	var err error
 	e.ESDescriptor, err = DecodeESDescriptor(sr, descSize)


Test patch:
diff --git a/mp4/esds_test.go b/mp4/esds_test.go
index 4050021..160a131 100644
--- a/mp4/esds_test.go
+++ b/mp4/esds_test.go
@@ -13,6 +13,7 @@ const (
 	esdsMp4Box   = `0000002a6573647300000000031c0000000414401500000000010d88000003f80505128856e500060102`
 	esdsEncAudio = `0000003365736473000000000380808022000000048080801440150018000003eb100002710005808080021190068080800102`
 	esdsLongEnd  = `0000002f65736473000000000321000000041140150002440001ea940001ea94050212100680808080808080800102`
+	esdsShort    = `0000002365736473000000000315000000040d6b150001e00002850000027100060102`
 )
 
 func TestEsdsEncodeAndDecode(t *testing.T) {
@@ -42,7 +43,7 @@ func TestEsdsEncodeAndDecode(t *testing.T) {
 	boxDiffAfterEncodeAndDecode(t, esdsIn)
 }
 func TestDecodeEncodeEsds(t *testing.T) {
-	inputs := []string{esdsProgIn, esdsMp4Box, esdsEncAudio, esdsLongEnd}
+	inputs := []string{esdsShort, esdsProgIn, esdsMp4Box, esdsEncAudio, esdsLongEnd}
 	for i, inp := range inputs {
 		data, err := hex.DecodeString(inp)
 		if err != nil {
Repository: Eyevinn/mp4ff
Pull request #405 (2025-01-20 17:54:04)

fix: co64 could use too much memory of the size overflowed 32 bits


Patch:
diff --git a/mp4/co64.go b/mp4/co64.go
index 1d40653..7034766 100644
--- a/mp4/co64.go
+++ b/mp4/co64.go
@@ -59,7 +59,7 @@ func (b *Co64Box) Type() string {
 }
 
 func (b *Co64Box) expectedSize(nrEntries uint32) uint64 {
-	return uint64(boxHeaderSize + 8 + nrEntries*8)
+	return uint64(boxHeaderSize + 8 + uint64(nrEntries)*8)
 }
 
 // Size - box-specific size


Test patch:
diff --git a/mp4/testdata/fuzz/FuzzDecodeBox/7e07cf8cc85e7f41 b/mp4/testdata/fuzz/FuzzDecodeBox/7e07cf8cc85e7f41
new file mode 100644
index 0000000..652d780
--- /dev/null
+++ b/mp4/testdata/fuzz/FuzzDecodeBox/7e07cf8cc85e7f41
@@ -0,0 +1,2 @@
+go test fuzz v1
+[]byte("\x00\x00\x00\x10co640000 \x00\x00\x00")