mirror of
				https://github.com/go-gitea/gitea.git
				synced 2025-10-29 10:57:44 +09:00 
			
		
		
		
	Vendor Update (#16121)
* update github.com/PuerkitoBio/goquery * update github.com/alecthomas/chroma * update github.com/blevesearch/bleve/v2 * update github.com/caddyserver/certmagic * update github.com/go-enry/go-enry/v2 * update github.com/go-git/go-billy/v5 * update github.com/go-git/go-git/v5 * update github.com/go-redis/redis/v8 * update github.com/go-testfixtures/testfixtures/v3 * update github.com/jaytaylor/html2text * update github.com/json-iterator/go * update github.com/klauspost/compress * update github.com/markbates/goth * update github.com/mattn/go-isatty * update github.com/mholt/archiver/v3 * update github.com/microcosm-cc/bluemonday * update github.com/minio/minio-go/v7 * update github.com/prometheus/client_golang * update github.com/unrolled/render * update github.com/xanzy/go-gitlab * update github.com/yuin/goldmark * update github.com/yuin/goldmark-highlighting Co-authored-by: techknowlogick <techknowlogick@gitea.io>
This commit is contained in:
		
							
								
								
									
										107
									
								
								vendor/github.com/klauspost/compress/zstd/framedec.go
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										107
									
								
								vendor/github.com/klauspost/compress/zstd/framedec.go
									
									
									
										generated
									
									
										vendored
									
									
								
							| @@ -78,44 +78,68 @@ func newFrameDec(o decoderOptions) *frameDec { | ||||
| func (d *frameDec) reset(br byteBuffer) error { | ||||
| 	d.HasCheckSum = false | ||||
| 	d.WindowSize = 0 | ||||
| 	var b []byte | ||||
| 	var signature [4]byte | ||||
| 	for { | ||||
| 		b = br.readSmall(4) | ||||
| 		if b == nil { | ||||
| 		var err error | ||||
| 		// Check if we can read more... | ||||
| 		b, err := br.readSmall(1) | ||||
| 		switch err { | ||||
| 		case io.EOF, io.ErrUnexpectedEOF: | ||||
| 			return io.EOF | ||||
| 		default: | ||||
| 			return err | ||||
| 		case nil: | ||||
| 			signature[0] = b[0] | ||||
| 		} | ||||
| 		if !bytes.Equal(b[1:4], skippableFrameMagic) || b[0]&0xf0 != 0x50 { | ||||
| 			if debug { | ||||
| 				println("Not skippable", hex.EncodeToString(b), hex.EncodeToString(skippableFrameMagic)) | ||||
| 		// Read the rest, don't allow io.ErrUnexpectedEOF | ||||
| 		b, err = br.readSmall(3) | ||||
| 		switch err { | ||||
| 		case io.EOF: | ||||
| 			return io.EOF | ||||
| 		default: | ||||
| 			return err | ||||
| 		case nil: | ||||
| 			copy(signature[1:], b) | ||||
| 		} | ||||
|  | ||||
| 		if !bytes.Equal(signature[1:4], skippableFrameMagic) || signature[0]&0xf0 != 0x50 { | ||||
| 			if debugDecoder { | ||||
| 				println("Not skippable", hex.EncodeToString(signature[:]), hex.EncodeToString(skippableFrameMagic)) | ||||
| 			} | ||||
| 			// Break if not skippable frame. | ||||
| 			break | ||||
| 		} | ||||
| 		// Read size to skip | ||||
| 		b = br.readSmall(4) | ||||
| 		if b == nil { | ||||
| 			println("Reading Frame Size EOF") | ||||
| 			return io.ErrUnexpectedEOF | ||||
| 		b, err = br.readSmall(4) | ||||
| 		if err != nil { | ||||
| 			if debugDecoder { | ||||
| 				println("Reading Frame Size", err) | ||||
| 			} | ||||
| 			return err | ||||
| 		} | ||||
| 		n := uint32(b[0]) | (uint32(b[1]) << 8) | (uint32(b[2]) << 16) | (uint32(b[3]) << 24) | ||||
| 		println("Skipping frame with", n, "bytes.") | ||||
| 		err := br.skipN(int(n)) | ||||
| 		err = br.skipN(int(n)) | ||||
| 		if err != nil { | ||||
| 			if debug { | ||||
| 			if debugDecoder { | ||||
| 				println("Reading discarded frame", err) | ||||
| 			} | ||||
| 			return err | ||||
| 		} | ||||
| 	} | ||||
| 	if !bytes.Equal(b, frameMagic) { | ||||
| 		println("Got magic numbers: ", b, "want:", frameMagic) | ||||
| 	if !bytes.Equal(signature[:], frameMagic) { | ||||
| 		if debugDecoder { | ||||
| 			println("Got magic numbers: ", signature, "want:", frameMagic) | ||||
| 		} | ||||
| 		return ErrMagicMismatch | ||||
| 	} | ||||
|  | ||||
| 	// Read Frame_Header_Descriptor | ||||
| 	fhd, err := br.readByte() | ||||
| 	if err != nil { | ||||
| 		println("Reading Frame_Header_Descriptor", err) | ||||
| 		if debugDecoder { | ||||
| 			println("Reading Frame_Header_Descriptor", err) | ||||
| 		} | ||||
| 		return err | ||||
| 	} | ||||
| 	d.SingleSegment = fhd&(1<<5) != 0 | ||||
| @@ -130,7 +154,9 @@ func (d *frameDec) reset(br byteBuffer) error { | ||||
| 	if !d.SingleSegment { | ||||
| 		wd, err := br.readByte() | ||||
| 		if err != nil { | ||||
| 			println("Reading Window_Descriptor", err) | ||||
| 			if debugDecoder { | ||||
| 				println("Reading Window_Descriptor", err) | ||||
| 			} | ||||
| 			return err | ||||
| 		} | ||||
| 		printf("raw: %x, mantissa: %d, exponent: %d\n", wd, wd&7, wd>>3) | ||||
| @@ -147,12 +173,11 @@ func (d *frameDec) reset(br byteBuffer) error { | ||||
| 		if size == 3 { | ||||
| 			size = 4 | ||||
| 		} | ||||
| 		b = br.readSmall(int(size)) | ||||
| 		if b == nil { | ||||
| 			if debug { | ||||
| 				println("Reading Dictionary_ID", io.ErrUnexpectedEOF) | ||||
| 			} | ||||
| 			return io.ErrUnexpectedEOF | ||||
|  | ||||
| 		b, err := br.readSmall(int(size)) | ||||
| 		if err != nil { | ||||
| 			println("Reading Dictionary_ID", err) | ||||
| 			return err | ||||
| 		} | ||||
| 		var id uint32 | ||||
| 		switch size { | ||||
| @@ -163,7 +188,7 @@ func (d *frameDec) reset(br byteBuffer) error { | ||||
| 		case 4: | ||||
| 			id = uint32(b[0]) | (uint32(b[1]) << 8) | (uint32(b[2]) << 16) | (uint32(b[3]) << 24) | ||||
| 		} | ||||
| 		if debug { | ||||
| 		if debugDecoder { | ||||
| 			println("Dict size", size, "ID:", id) | ||||
| 		} | ||||
| 		if id > 0 { | ||||
| @@ -187,10 +212,10 @@ func (d *frameDec) reset(br byteBuffer) error { | ||||
| 	} | ||||
| 	d.FrameContentSize = 0 | ||||
| 	if fcsSize > 0 { | ||||
| 		b := br.readSmall(fcsSize) | ||||
| 		if b == nil { | ||||
| 			println("Reading Frame content", io.ErrUnexpectedEOF) | ||||
| 			return io.ErrUnexpectedEOF | ||||
| 		b, err := br.readSmall(fcsSize) | ||||
| 		if err != nil { | ||||
| 			println("Reading Frame content", err) | ||||
| 			return err | ||||
| 		} | ||||
| 		switch fcsSize { | ||||
| 		case 1: | ||||
| @@ -205,7 +230,7 @@ func (d *frameDec) reset(br byteBuffer) error { | ||||
| 			d2 := uint32(b[4]) | (uint32(b[5]) << 8) | (uint32(b[6]) << 16) | (uint32(b[7]) << 24) | ||||
| 			d.FrameContentSize = uint64(d1) | (uint64(d2) << 32) | ||||
| 		} | ||||
| 		if debug { | ||||
| 		if debugDecoder { | ||||
| 			println("field size bits:", v, "fcsSize:", fcsSize, "FrameContentSize:", d.FrameContentSize, hex.EncodeToString(b[:fcsSize]), "singleseg:", d.SingleSegment, "window:", d.WindowSize) | ||||
| 		} | ||||
| 	} | ||||
| @@ -248,7 +273,7 @@ func (d *frameDec) reset(br byteBuffer) error { | ||||
|  | ||||
| // next will start decoding the next block from stream. | ||||
| func (d *frameDec) next(block *blockDec) error { | ||||
| 	if debug { | ||||
| 	if debugDecoder { | ||||
| 		printf("decoding new block %p:%p", block, block.data) | ||||
| 	} | ||||
| 	err := block.reset(d.rawInput, d.WindowSize) | ||||
| @@ -259,7 +284,7 @@ func (d *frameDec) next(block *blockDec) error { | ||||
| 		return err | ||||
| 	} | ||||
| 	block.input <- struct{}{} | ||||
| 	if debug { | ||||
| 	if debugDecoder { | ||||
| 		println("next block:", block) | ||||
| 	} | ||||
| 	d.asyncRunningMu.Lock() | ||||
| @@ -307,19 +332,19 @@ func (d *frameDec) checkCRC() error { | ||||
| 	tmp[3] = byte(got >> 24) | ||||
|  | ||||
| 	// We can overwrite upper tmp now | ||||
| 	want := d.rawInput.readSmall(4) | ||||
| 	if want == nil { | ||||
| 		println("CRC missing?") | ||||
| 		return io.ErrUnexpectedEOF | ||||
| 	want, err := d.rawInput.readSmall(4) | ||||
| 	if err != nil { | ||||
| 		println("CRC missing?", err) | ||||
| 		return err | ||||
| 	} | ||||
|  | ||||
| 	if !bytes.Equal(tmp[:], want) { | ||||
| 		if debug { | ||||
| 		if debugDecoder { | ||||
| 			println("CRC Check Failed:", tmp[:], "!=", want) | ||||
| 		} | ||||
| 		return ErrCRCMismatch | ||||
| 	} | ||||
| 	if debug { | ||||
| 	if debugDecoder { | ||||
| 		println("CRC ok", tmp[:]) | ||||
| 	} | ||||
| 	return nil | ||||
| @@ -340,7 +365,7 @@ func (d *frameDec) initAsync() { | ||||
| 	if cap(d.decoding) < d.o.concurrent { | ||||
| 		d.decoding = make(chan *blockDec, d.o.concurrent) | ||||
| 	} | ||||
| 	if debug { | ||||
| 	if debugDecoder { | ||||
| 		h := d.history | ||||
| 		printf("history init. len: %d, cap: %d", len(h.b), cap(h.b)) | ||||
| 	} | ||||
| @@ -388,7 +413,7 @@ func (d *frameDec) startDecoder(output chan decodeOutput) { | ||||
| 			output <- r | ||||
| 			return | ||||
| 		} | ||||
| 		if debug { | ||||
| 		if debugDecoder { | ||||
| 			println("got result, from ", d.offset, "to", d.offset+int64(len(r.b))) | ||||
| 			d.offset += int64(len(r.b)) | ||||
| 		} | ||||
| @@ -396,7 +421,7 @@ func (d *frameDec) startDecoder(output chan decodeOutput) { | ||||
| 			// Send history to next block | ||||
| 			select { | ||||
| 			case next = <-d.decoding: | ||||
| 				if debug { | ||||
| 				if debugDecoder { | ||||
| 					println("Sending ", len(d.history.b), "bytes as history") | ||||
| 				} | ||||
| 				next.history <- &d.history | ||||
| @@ -434,7 +459,7 @@ func (d *frameDec) startDecoder(output chan decodeOutput) { | ||||
| 		output <- r | ||||
| 		if next == nil { | ||||
| 			// There was no decoder available, we wait for one now that we have sent to the writer. | ||||
| 			if debug { | ||||
| 			if debugDecoder { | ||||
| 				println("Sending ", len(d.history.b), " bytes as history") | ||||
| 			} | ||||
| 			next = <-d.decoding | ||||
| @@ -458,7 +483,7 @@ func (d *frameDec) runDecoder(dst []byte, dec *blockDec) ([]byte, error) { | ||||
| 		if err != nil { | ||||
| 			break | ||||
| 		} | ||||
| 		if debug { | ||||
| 		if debugDecoder { | ||||
| 			println("next block:", dec) | ||||
| 		} | ||||
| 		err = dec.decodeBuf(&d.history) | ||||
|   | ||||
		Reference in New Issue
	
	Block a user