Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The hostname and password cannot parse even if escaping with RedisURI redis-sentinel the password include '@' and '#' #2254

Closed
coolbeevip opened this issue Nov 20, 2022 · 0 comments
Assignees
Labels
type: bug A general bug
Milestone

Comments

@coolbeevip
Copy link
Contributor

Bug Report

The hostname and password cannot parse even if escaping with RedisURI the password include '@'

Current Behavior

Redis password is abc@#123. escaping is abc%40%23123

This test case

  @Test
  public void sentinelUriTest() {
    RedisURI redisURI = RedisURI.create("redis-sentinel://abc%40%23123@h1:6397,h2:6397,h3:6397/5?sentinelMasterId=masterId");
    assertThat(redisURI.getSentinels().get(0).getHost(), Matchers.is("h1"));
    assertThat(String.valueOf(redisURI.getPassword()), Matchers.is("abc@#123"));
  }

Test failed

java.lang.AssertionError: 
Expected: is "h1"
     but: was "#123@h1"
Expected :h1
Actual   :#123@h1

Environment

  • Lettuce version(s): 6.1.10.RELEASE

Possible Solution

Here authority.indexOf('@') should be changed to authority.lastIndexOf('@')

https://github.com/lettuce-io/lettuce-core/blob/main/src/main/java/io/lettuce/core/RedisURI.java#L1161

@coolbeevip coolbeevip changed the title The hostname and password cannot parse even if escaping with RedisURI the password include '@' and '#' The hostname and password cannot parse even if escaping with RedisURI redis-sentinel the password include '@' and '#' Nov 20, 2022
@mp911de mp911de self-assigned this Nov 21, 2022
@mp911de mp911de added the type: bug A general bug label Nov 21, 2022
mp911de pushed a commit that referenced this issue Nov 22, 2022
mp911de pushed a commit that referenced this issue Nov 22, 2022
@mp911de mp911de added this to the 6.2.2.RELEASE milestone Nov 22, 2022
@mp911de mp911de closed this as completed Nov 22, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: bug A general bug
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants