Ignore invalid image URLs
This commit is contained in:
@@ -113,6 +113,7 @@ func Init() (err error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
showInfo(fmt.Sprintf("Version:%s Build: %s", System.Version, System.Build))
|
showInfo(fmt.Sprintf("Version:%s Build: %s", System.Version, System.Build))
|
||||||
|
showInfo(fmt.Sprintf("Database Version:%s", System.DBVersion))
|
||||||
showInfo(fmt.Sprintf("System IP Addresses:IPv4: %d | IPv6: %d", len(System.IPAddressesV4), len(System.IPAddressesV6)))
|
showInfo(fmt.Sprintf("System IP Addresses:IPv4: %d | IPv6: %d", len(System.IPAddressesV4), len(System.IPAddressesV6)))
|
||||||
showInfo("Hostname:" + System.Hostname)
|
showInfo("Hostname:" + System.Hostname)
|
||||||
showInfo(fmt.Sprintf("System Folder:%s", getPlatformPath(System.Folder.Config)))
|
showInfo(fmt.Sprintf("System Folder:%s", getPlatformPath(System.Folder.Config)))
|
||||||
|
|||||||
@@ -6,24 +6,41 @@ import (
|
|||||||
"io"
|
"io"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"net/http"
|
"net/http"
|
||||||
|
"net/url"
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"strings"
|
"strings"
|
||||||
)
|
)
|
||||||
|
|
||||||
func getCacheImageURL(url string) (cacheImageURL string) {
|
func getCacheImageURL(imageURL string) (cacheImageURL string) {
|
||||||
|
|
||||||
url = strings.Trim(url, "\r\n")
|
if Settings.CacheImages == false {
|
||||||
|
return imageURL
|
||||||
|
}
|
||||||
|
|
||||||
var urlMD5 = getMD5(url)
|
imageURL = strings.Trim(imageURL, "\r\n")
|
||||||
var fileExtension = filepath.Ext(url)
|
|
||||||
|
p, err := url.Parse(imageURL)
|
||||||
|
if err != nil {
|
||||||
|
// URL konnte nicht geparst werden, die ursprüngliche image url wird zurückgegeben
|
||||||
|
showInfo(fmt.Sprintf("Image Caching:Image URL: %s", imageURL))
|
||||||
|
showWarning(4101)
|
||||||
|
return imageURL
|
||||||
|
}
|
||||||
|
var urlMD5 = getMD5(imageURL)
|
||||||
|
var fileExtension = filepath.Ext(p.Path)
|
||||||
|
|
||||||
|
if len(fileExtension) == 0 {
|
||||||
|
// Keine Dateierweiterung vorhanden, die ursprüngliche image url wird zurückgegeben
|
||||||
|
return imageURL
|
||||||
|
}
|
||||||
|
|
||||||
if indexOfString(urlMD5+fileExtension, Data.Cache.ImagesFiles) == -1 {
|
if indexOfString(urlMD5+fileExtension, Data.Cache.ImagesFiles) == -1 {
|
||||||
Data.Cache.ImagesFiles = append(Data.Cache.ImagesFiles, urlMD5+fileExtension)
|
Data.Cache.ImagesFiles = append(Data.Cache.ImagesFiles, urlMD5+fileExtension)
|
||||||
}
|
}
|
||||||
|
|
||||||
if Settings.CacheImages == false || System.ImageCachingInProgress == 1 {
|
if System.ImageCachingInProgress == 1 {
|
||||||
return url
|
return imageURL
|
||||||
}
|
}
|
||||||
|
|
||||||
if indexOfString(urlMD5+fileExtension, Data.Cache.ImagesCache) != -1 {
|
if indexOfString(urlMD5+fileExtension, Data.Cache.ImagesCache) != -1 {
|
||||||
@@ -32,15 +49,15 @@ func getCacheImageURL(url string) (cacheImageURL string) {
|
|||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
if strings.Contains(url, System.Domain+"/images/") == false {
|
if strings.Contains(imageURL, System.Domain+"/images/") == false {
|
||||||
|
|
||||||
if indexOfString(url, Data.Cache.ImagesURLS) == -1 {
|
if indexOfString(imageURL, Data.Cache.ImagesURLS) == -1 {
|
||||||
Data.Cache.ImagesURLS = append(Data.Cache.ImagesURLS, url)
|
Data.Cache.ImagesURLS = append(Data.Cache.ImagesURLS, imageURL)
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
cacheImageURL = url
|
cacheImageURL = imageURL
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -57,10 +74,10 @@ func cachingImages() {
|
|||||||
|
|
||||||
showInfo("Image Caching:Images are cached")
|
showInfo("Image Caching:Images are cached")
|
||||||
|
|
||||||
for _, url := range Data.Cache.ImagesURLS {
|
for _, imageURL := range Data.Cache.ImagesURLS {
|
||||||
|
|
||||||
if len(url) > 0 {
|
if len(imageURL) > 0 {
|
||||||
cacheImage(url)
|
cacheImage(imageURL)
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -94,16 +111,16 @@ func cachingImages() {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
func cacheImage(url string) {
|
func cacheImage(imageURL string) {
|
||||||
|
|
||||||
var debug string
|
var debug string
|
||||||
var urlMD5 = getMD5(url)
|
var urlMD5 = getMD5(imageURL)
|
||||||
var fileExtension = filepath.Ext(url)
|
var fileExtension = filepath.Ext(imageURL)
|
||||||
|
|
||||||
debug = fmt.Sprintf("Image Caching:File: %s Download: %s", urlMD5+fileExtension, url)
|
debug = fmt.Sprintf("Image Caching:File: %s Download: %s", urlMD5+fileExtension, imageURL)
|
||||||
showDebug(debug, 1)
|
showDebug(debug, 1)
|
||||||
|
|
||||||
resp, err := http.Get(url)
|
resp, err := http.Get(imageURL)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -351,6 +351,8 @@ func getErrMsg(errCode int) (errMsg string) {
|
|||||||
// Caching
|
// Caching
|
||||||
case 4100:
|
case 4100:
|
||||||
errMsg = fmt.Sprintf("Unknown content type for downloaded image")
|
errMsg = fmt.Sprintf("Unknown content type for downloaded image")
|
||||||
|
case 4101:
|
||||||
|
errMsg = fmt.Sprintf("Invalid URL, original URL is used for this image")
|
||||||
|
|
||||||
// API
|
// API
|
||||||
case 5000:
|
case 5000:
|
||||||
|
|||||||
@@ -15,6 +15,7 @@ type SystemStruct struct {
|
|||||||
Build string
|
Build string
|
||||||
Compatibility string
|
Compatibility string
|
||||||
ConfigurationWizard bool
|
ConfigurationWizard bool
|
||||||
|
DBVersion string
|
||||||
Dev bool
|
Dev bool
|
||||||
DeviceID string
|
DeviceID string
|
||||||
Domain string
|
Domain string
|
||||||
|
|||||||
@@ -133,7 +133,7 @@ func loadSettings() (settings SettingsStrcut, err error) {
|
|||||||
defaults["update"] = []string{"0000"}
|
defaults["update"] = []string{"0000"}
|
||||||
defaults["user.agent"] = System.Name
|
defaults["user.agent"] = System.Name
|
||||||
defaults["uuid"] = createUUID()
|
defaults["uuid"] = createUUID()
|
||||||
defaults["version"] = System.Version
|
defaults["version"] = System.DBVersion
|
||||||
defaults["xteveAutoUpdate"] = true
|
defaults["xteveAutoUpdate"] = true
|
||||||
defaults["temp.path"] = System.Folder.Temp
|
defaults["temp.path"] = System.Folder.Temp
|
||||||
|
|
||||||
@@ -159,6 +159,8 @@ func loadSettings() (settings SettingsStrcut, err error) {
|
|||||||
showInfo(fmt.Sprintf("Git Branch:Switching Git Branch to -> %s", settings.Branch))
|
showInfo(fmt.Sprintf("Git Branch:Switching Git Branch to -> %s", settings.Branch))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
settings.Version = System.DBVersion
|
||||||
|
|
||||||
err = saveSettings(settings)
|
err = saveSettings(settings)
|
||||||
|
|
||||||
return
|
return
|
||||||
|
|||||||
@@ -189,7 +189,7 @@ checkVersion:
|
|||||||
var newFilterMap = convertToNewFilter(oldFilter)
|
var newFilterMap = convertToNewFilter(oldFilter)
|
||||||
settingsMap["filter"] = newFilterMap
|
settingsMap["filter"] = newFilterMap
|
||||||
|
|
||||||
settingsMap["version"] = "1.9.0"
|
settingsMap["version"] = "2.0.0"
|
||||||
|
|
||||||
err = saveMapToJSONFile(System.File.Settings, settingsMap)
|
err = saveMapToJSONFile(System.File.Settings, settingsMap)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -203,7 +203,7 @@ checkVersion:
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
case "1.9.0":
|
case "2.0.0":
|
||||||
// Falls es in einem späteren Update Änderungen an der Datenbank gibt, geht es hier weiter
|
// Falls es in einem späteren Update Änderungen an der Datenbank gibt, geht es hier weiter
|
||||||
|
|
||||||
break
|
break
|
||||||
|
|||||||
6
xteve.go
6
xteve.go
@@ -39,7 +39,10 @@ var GitHub = GitHubStruct{Branch: "master", User: "xteve-project", Repo: "xTeVe-
|
|||||||
const Name = "xTeVe"
|
const Name = "xTeVe"
|
||||||
|
|
||||||
// Version : Version, die Build Nummer wird in der main func geparst.
|
// Version : Version, die Build Nummer wird in der main func geparst.
|
||||||
const Version = "2.0.0.0000"
|
const Version = "2.0.0.0001"
|
||||||
|
|
||||||
|
// DBVersion : Datanbank Version
|
||||||
|
const DBVersion = "2.0.0"
|
||||||
|
|
||||||
// APIVersion : API Version
|
// APIVersion : API Version
|
||||||
const APIVersion = "1.1.0"
|
const APIVersion = "1.1.0"
|
||||||
@@ -66,6 +69,7 @@ func main() {
|
|||||||
system.APIVersion = APIVersion
|
system.APIVersion = APIVersion
|
||||||
system.Branch = GitHub.Branch
|
system.Branch = GitHub.Branch
|
||||||
system.Build = build[len(build)-1:][0]
|
system.Build = build[len(build)-1:][0]
|
||||||
|
system.DBVersion = DBVersion
|
||||||
system.Dev = Dev
|
system.Dev = Dev
|
||||||
system.GitHub = GitHub
|
system.GitHub = GitHub
|
||||||
system.Name = Name
|
system.Name = Name
|
||||||
|
|||||||
Reference in New Issue
Block a user