mirror of
				https://github.com/zadam/trilium.git
				synced 2025-10-31 03:29:02 +01:00 
			
		
		
		
	Merge pull request #3142 from spasche/zip-import-skip-bad-url
let import continue when malformed URLs are encountered
This commit is contained in:
		
						commit
						fb6a0bc2a6
					
				| @ -292,7 +292,12 @@ async function importZip(taskContext, fileBuffer, importRootNote) { | |||||||
|             content = content.replace(/<\/body>.*<\/html>/gis, ""); |             content = content.replace(/<\/body>.*<\/html>/gis, ""); | ||||||
| 
 | 
 | ||||||
|             content = content.replace(/src="([^"]*)"/g, (match, url) => { |             content = content.replace(/src="([^"]*)"/g, (match, url) => { | ||||||
|                 url = decodeURIComponent(url); |                 try { | ||||||
|  |                     url = decodeURIComponent(url); | ||||||
|  |                 } catch (e) { | ||||||
|  |                     log.error(`Cannot parse image URL '${url}', keeping original (${e}).`); | ||||||
|  |                     return `src="${url}"`; | ||||||
|  |                 } | ||||||
| 
 | 
 | ||||||
|                 if (isUrlAbsolute(url) || url.startsWith("/")) { |                 if (isUrlAbsolute(url) || url.startsWith("/")) { | ||||||
|                     return match; |                     return match; | ||||||
| @ -304,7 +309,12 @@ async function importZip(taskContext, fileBuffer, importRootNote) { | |||||||
|             }); |             }); | ||||||
| 
 | 
 | ||||||
|             content = content.replace(/href="([^"]*)"/g, (match, url) => { |             content = content.replace(/href="([^"]*)"/g, (match, url) => { | ||||||
|                 url = decodeURIComponent(url); |                 try { | ||||||
|  |                     url = decodeURIComponent(url); | ||||||
|  |                 } catch (e) { | ||||||
|  |                     log.error(`Cannot parse link URL '${url}', keeping original (${e}).`); | ||||||
|  |                     return `href="${url}"`; | ||||||
|  |                 } | ||||||
| 
 | 
 | ||||||
|                 if (isUrlAbsolute(url)) { |                 if (isUrlAbsolute(url)) { | ||||||
|                     return match; |                     return match; | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user
	 zadam
						zadam