mirror of
				https://github.com/zadam/trilium.git
				synced 2025-10-27 01:28:59 +01:00 
			
		
		
		
	avoid various HTTP server issues with slashes by putting notePath into the body with POST
This commit is contained in:
		
							parent
							
								
									a7fce33750
								
							
						
					
					
						commit
						c1ce0c6b22
					
				| @ -331,7 +331,7 @@ function addRecentNote(branchId, notePath) { | |||||||
|     setTimeout(async () => { |     setTimeout(async () => { | ||||||
|         // we include the note into recent list only if the user stayed on the note at least 5 seconds
 |         // we include the note into recent list only if the user stayed on the note at least 5 seconds
 | ||||||
|         if (notePath && notePath === getCurrentNotePath()) { |         if (notePath && notePath === getCurrentNotePath()) { | ||||||
|             await server.put('recent-notes/' + branchId + '/' + encodeURIComponent(notePath)); |             await server.post('recent-notes', { branchId, notePath }); | ||||||
|         } |         } | ||||||
|     }, 1500); |     }, 1500); | ||||||
| } | } | ||||||
|  | |||||||
| @ -4,8 +4,8 @@ const optionService = require('../../services/options'); | |||||||
| const RecentNote = require('../../entities/recent_note'); | const RecentNote = require('../../entities/recent_note'); | ||||||
| 
 | 
 | ||||||
| async function addRecentNote(req) { | async function addRecentNote(req) { | ||||||
|     const branchId = req.params.branchId; |     const branchId = req.body.branchId; | ||||||
|     const notePath = req.params.notePath; |     const notePath = req.body.notePath; | ||||||
| 
 | 
 | ||||||
|     await new RecentNote({ |     await new RecentNote({ | ||||||
|         branchId: branchId, |         branchId: branchId, | ||||||
|  | |||||||
| @ -172,9 +172,7 @@ function register(app) { | |||||||
| 
 | 
 | ||||||
|     apiRoute(GET, '/api/event-log', eventLogRoute.getEventLog); |     apiRoute(GET, '/api/event-log', eventLogRoute.getEventLog); | ||||||
| 
 | 
 | ||||||
|     // * at the end means this will match params containing slash as well
 |     apiRoute(POST, '/api/recent-notes', recentNotesRoute.addRecentNote); | ||||||
|     // this is a problem with nginx (and possibly other proxies) which translate escaped slash back to the literal slash character
 |  | ||||||
|     apiRoute(PUT, '/api/recent-notes/:branchId/:notePath*', recentNotesRoute.addRecentNote); |  | ||||||
|     apiRoute(GET, '/api/app-info', appInfoRoute.getAppInfo); |     apiRoute(GET, '/api/app-info', appInfoRoute.getAppInfo); | ||||||
| 
 | 
 | ||||||
|     route(GET, '/api/setup/status', [], setupApiRoute.getStatus, apiResultHandler); |     route(GET, '/api/setup/status', [], setupApiRoute.getStatus, apiResultHandler); | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user
	 zadam
						zadam