Skip to content

Fix query string parsing regression introduced in 2.18.2 #3106 #3341

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

Merged
merged 3 commits into from
Jun 25, 2025

Conversation

C0deBeez
Copy link
Contributor

Fix query string parsing regression introduced in 2.18.2

This PR fixes a regression introduced in Dash 2.18.2 where query string values containing unencoded & characters were being truncated at the first &.

Problem: In 2.18.2, ?param1=something&bla&param2=something2 would result in param1='something' instead of the expected param1='something&bla' from 2.18.1.

Root Cause: The automatic URL decoding feature from #2991 caused unquote() to decode %26 to &, which parse_qs() then misinterpreted as parameter delimiters.

Solution: Remove the automatic unquote() call to restore 2.18.1 behavior while maintaining support for properly encoded URLs.

Fixes #3106

Contributor Checklist

  • I have added entry in the CHANGELOG.md

Changes Made

# Before (2.18.2) - BROKEN
def _parse_query_string(search):
    search = unquote(search)   # REMOVED
    if search and len(search) > 0 and search[0] == "?":
        search = search[1:]
    else:
        parsed_qs = {}
    for (k, v) in parse_qs(search).items():
        v = v[0] if len(v) == 1 else v
        parsed_qs[k] = v
    return parsed_qs

# After (This Fix) - WORKING
def _parse_query_string(search):
    if not search or not search.startswith("?"):
        return {}

    query_string = search[1:]
    
    parsed_qs = parse_qs(query_string, keep_blank_values=True)
    
    return {
        k: v[0] if len(v) == 1 else v
        for k, v in parsed_qs.items()
    }

@gvwilson gvwilson added regression this used to work P1 needed for current cycle fix fixes something broken community community contribution labels Jun 25, 2025
@gvwilson
Copy link
Contributor

@T4rk1n please review

Copy link
Contributor

@T4rk1n T4rk1n left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💃 Looks good, thank you.

@T4rk1n T4rk1n merged commit 11fbbdf into plotly:dev Jun 25, 2025
9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
community community contribution fix fixes something broken P1 needed for current cycle regression this used to work
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Search param removes values after ampersand, introduced in 2.18.2
3 participants