mirror of
https://github.com/go-shiori/shiori.git
synced 2025-01-17 05:17:59 +08:00
Fix relative URL allowed
This commit is contained in:
parent
fd1f190800
commit
ffa2497c5f
2 changed files with 14 additions and 12 deletions
|
@ -62,7 +62,7 @@ func addBookmark(base model.Bookmark, offline bool) (book model.Bookmark, err er
|
|||
|
||||
// Make sure URL valid
|
||||
parsedURL, err := nurl.ParseRequestURI(book.URL)
|
||||
if err != nil {
|
||||
if err != nil || parsedURL.Host == "" {
|
||||
return book, fmt.Errorf("URL is not valid")
|
||||
}
|
||||
|
||||
|
|
|
@ -101,16 +101,18 @@ func init() {
|
|||
func updateBookmarks(indices []string, base model.Bookmark, offline, overwrite bool) ([]model.Bookmark, error) {
|
||||
mutex := sync.Mutex{}
|
||||
|
||||
// Make sure URL valid
|
||||
parsedURL, err := nurl.ParseRequestURI(base.URL)
|
||||
if err != nil {
|
||||
return []model.Bookmark{}, fmt.Errorf("URL is not valid")
|
||||
}
|
||||
if base.URL != "" {
|
||||
// Make sure URL valid
|
||||
parsedURL, err := nurl.ParseRequestURI(base.URL)
|
||||
if err != nil || parsedURL.Host == "" {
|
||||
return []model.Bookmark{}, fmt.Errorf("URL is not valid")
|
||||
}
|
||||
|
||||
// Clear UTM parameters from URL
|
||||
url, err := clearUTMParams(parsedURL)
|
||||
if err != nil {
|
||||
return []model.Bookmark{}, err
|
||||
// Clear UTM parameters from URL
|
||||
base.URL, err = clearUTMParams(parsedURL)
|
||||
if err != nil {
|
||||
return []model.Bookmark{}, err
|
||||
}
|
||||
}
|
||||
|
||||
// Read bookmarks from database
|
||||
|
@ -123,8 +125,8 @@ func updateBookmarks(indices []string, base model.Bookmark, offline, overwrite b
|
|||
return []model.Bookmark{}, fmt.Errorf("No matching index found")
|
||||
}
|
||||
|
||||
if url != "" && len(bookmarks) == 1 {
|
||||
bookmarks[0].URL = url
|
||||
if base.URL != "" && len(bookmarks) == 1 {
|
||||
bookmarks[0].URL = base.URL
|
||||
}
|
||||
|
||||
// If not offline, fetch articles from internet
|
||||
|
|
Loading…
Reference in a new issue