mirror of
				https://github.com/neovim/neovim.git
				synced 2025-11-04 01:34:25 +00:00 
			
		
		
		
	fix(uri): uri_encode encodes brackets incorrectly for RFC2732 #31284
**Problem:** The brackets in the RFC2732 regular expression are currently unescaped, causing them to be misinterpreted as special characters denoting character groups rather than as literal characters. **Solution:** Escape the brackets. Fix #31270
This commit is contained in:
		@@ -15,7 +15,7 @@ local PATTERNS = {
 | 
				
			|||||||
  rfc2396 = "^A-Za-z0-9%-_.!~*'()",
 | 
					  rfc2396 = "^A-Za-z0-9%-_.!~*'()",
 | 
				
			||||||
  -- RFC 2732
 | 
					  -- RFC 2732
 | 
				
			||||||
  -- https://tools.ietf.org/html/rfc2732
 | 
					  -- https://tools.ietf.org/html/rfc2732
 | 
				
			||||||
  rfc2732 = "^A-Za-z0-9%-_.!~*'()[]",
 | 
					  rfc2732 = "^A-Za-z0-9%-_.!~*'()%[%]",
 | 
				
			||||||
  -- RFC 3986
 | 
					  -- RFC 3986
 | 
				
			||||||
  -- https://tools.ietf.org/html/rfc3986#section-2.2
 | 
					  -- https://tools.ietf.org/html/rfc3986#section-2.2
 | 
				
			||||||
  rfc3986 = "^A-Za-z0-9%-._~!$&'()*+,;=:@/",
 | 
					  rfc3986 = "^A-Za-z0-9%-._~!$&'()*+,;=:@/",
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -252,4 +252,12 @@ describe('URI methods', function()
 | 
				
			|||||||
      end
 | 
					      end
 | 
				
			||||||
    )
 | 
					    )
 | 
				
			||||||
  end)
 | 
					  end)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  describe('encode to uri', function()
 | 
				
			||||||
 | 
					    it('rfc2732 including brackets', function()
 | 
				
			||||||
 | 
					      exec_lua("str = '[:]'")
 | 
				
			||||||
 | 
					      exec_lua("rfc = 'rfc2732'")
 | 
				
			||||||
 | 
					      eq('[%3a]', exec_lua('return vim.uri_encode(str, rfc)'))
 | 
				
			||||||
 | 
					    end)
 | 
				
			||||||
 | 
					  end)
 | 
				
			||||||
end)
 | 
					end)
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user