mirror of
https://github.com/moonD4rk/HackBrowserData.git
synced 2026-06-06 19:53:53 +02:00
feat: test case for convert utf16 value to utf8
This commit is contained in:
@@ -8,6 +8,8 @@ import (
|
||||
"strings"
|
||||
|
||||
"github.com/syndtr/goleveldb/leveldb"
|
||||
"golang.org/x/text/encoding/unicode"
|
||||
"golang.org/x/text/transform"
|
||||
|
||||
"github.com/moond4rk/HackBrowserData/item"
|
||||
"github.com/moond4rk/HackBrowserData/log"
|
||||
@@ -44,7 +46,7 @@ func (c *ChromiumLocalStorage) Parse(masterKey []byte) error {
|
||||
if len(value) < maxLocalStorageLength {
|
||||
s.fillValue(value)
|
||||
} else {
|
||||
s.Value = fmt.Sprintf("value is too long, length is %d", len(value))
|
||||
s.Value = fmt.Sprintf("value is too long, length is %d, supportted max length is %d", len(value), maxLocalStorageLength)
|
||||
}
|
||||
if s.IsMeta {
|
||||
s.Value = fmt.Sprintf("meta data, value bytes is %v", value)
|
||||
@@ -84,6 +86,11 @@ func (s *storage) fillHeader(url, key []byte) {
|
||||
s.Key = string(bytes.Trim(key, "\x01"))
|
||||
}
|
||||
|
||||
func convertUTF16toUTF8(source []byte, endian unicode.Endianness) ([]byte, error) {
|
||||
r, _, err := transform.Bytes(unicode.UTF16(endian, unicode.IgnoreBOM).NewDecoder(), source)
|
||||
return r, err
|
||||
}
|
||||
|
||||
// fillValue fills value of the storage
|
||||
// TODO: support unicode charter
|
||||
func (s *storage) fillValue(b []byte) {
|
||||
|
||||
Reference in New Issue
Block a user