mirror of
				https://github.com/zadam/trilium.git
				synced 2025-10-31 03:29:02 +01:00 
			
		
		
		
	contrary to what I believed encodeURIComponent() is available also in node.js, #4478
This commit is contained in:
		
							parent
							
								
									ad74952194
								
							
						
					
					
						commit
						d07f02b95f
					
				| @ -154,9 +154,8 @@ function processContent(images, note, content) { | |||||||
| 
 | 
 | ||||||
|             const attachment = imageService.saveImageToAttachment(note.noteId, buffer, filename, true); |             const attachment = imageService.saveImageToAttachment(note.noteId, buffer, filename, true); | ||||||
| 
 | 
 | ||||||
|             // We might want to replace with escape-html. For non-latin-based languages, this doesn't work well.
 |             const encodedTitle = encodeURIComponent(attachment.title); | ||||||
|             const sanitizedTitle = attachment.title.replace(/[^a-z0-9-.]/gi, "") || "attachment"; |             const url = `api/attachments/${attachment.attachmentId}/image/${encodedTitle}`; | ||||||
|             const url = `api/attachments/${attachment.attachmentId}/image/${sanitizedTitle}`; |  | ||||||
| 
 | 
 | ||||||
|             log.info(`Replacing '${imageId}' with '${url}' in note '${note.noteId}'`); |             log.info(`Replacing '${imageId}' with '${url}' in note '${note.noteId}'`); | ||||||
| 
 | 
 | ||||||
|  | |||||||
| @ -303,9 +303,8 @@ function importEnex(taskContext, file, parentNote) { | |||||||
| 
 | 
 | ||||||
|                     const attachment = imageService.saveImageToAttachment(noteEntity.noteId, resource.content, originalName, taskContext.data.shrinkImages); |                     const attachment = imageService.saveImageToAttachment(noteEntity.noteId, resource.content, originalName, taskContext.data.shrinkImages); | ||||||
| 
 | 
 | ||||||
|                     // We might want to replace with escape-html. For non-latin-based languages, this doesn't work well.
 |                     const encodedTitle = encodeURIComponent(attachment.title); | ||||||
|                     const sanitizedTitle = attachment.title.replace(/[^a-z0-9-.]/gi, "") || "attachment"; |                     const url = `api/attachments/${attachment.attachmentId}/image/${encodedTitle}`; | ||||||
|                     const url = `api/attachments/${attachment.attachmentId}/image/${sanitizedTitle}`; |  | ||||||
|                     const imageLink = `<img src="${url}">`; |                     const imageLink = `<img src="${url}">`; | ||||||
| 
 | 
 | ||||||
|                     content = content.replace(mediaRegex, imageLink); |                     content = content.replace(mediaRegex, imageLink); | ||||||
|  | |||||||
| @ -529,10 +529,9 @@ function downloadImages(noteId, content) { | |||||||
|             const imageService = require('../services/image'); |             const imageService = require('../services/image'); | ||||||
|             const attachment = imageService.saveImageToAttachment(noteId, imageBuffer, "inline image", true, true); |             const attachment = imageService.saveImageToAttachment(noteId, imageBuffer, "inline image", true, true); | ||||||
| 
 | 
 | ||||||
|             // We might want to replace with escape-html. For non-latin-based languages, this doesn't work well.
 |             const encodedTitle = encodeURIComponent(attachment.title); | ||||||
|             const sanitizedTitle = attachment.title.replace(/[^a-z0-9-.]/gi, "") || "attachment"; |  | ||||||
| 
 | 
 | ||||||
|             content = `${content.substr(0, imageMatch.index)}<img src="api/attachments/${attachment.attachmentId}/image/${sanitizedTitle}"${content.substr(imageMatch.index + imageMatch[0].length)}`; |             content = `${content.substr(0, imageMatch.index)}<img src="api/attachments/${attachment.attachmentId}/image/${encodedTitle}"${content.substr(imageMatch.index + imageMatch[0].length)}`; | ||||||
|         } |         } | ||||||
|         else if (!url.includes('api/images/') && !/api\/attachments\/.+\/image\/?.*/.test(url) |         else if (!url.includes('api/images/') && !/api\/attachments\/.+\/image\/?.*/.test(url) | ||||||
|             // this is an exception for the web clipper's "imageId"
 |             // this is an exception for the web clipper's "imageId"
 | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user
	 zadam
						zadam