Skip to content

fix(lofin): Add URL encoding for filter parameter values (#290)#298

Merged
yeongseon merged 1 commit into
mainfrom
fix/issue-290-lofin-url-encoding
Jul 3, 2026
Merged

fix(lofin): Add URL encoding for filter parameter values (#290)#298
yeongseon merged 1 commit into
mainfrom
fix/issue-290-lofin-url-encoding

Conversation

@yeongseon

Copy link
Copy Markdown
Owner

Summary

Closes #290

로핀(LOFIN) 어댑터의 필터 파라미터 값에 URL 인코딩을 추가하여 한글, 공백, 특수문자가 포함된 경우에도 올바른 요청을 전송하도록 수정했습니다.

Problem

src/kpubdata/providers/lofin/adapter.py 약 219번째 줄에서 필터 값을 URL에 직접 문자열 결합하여 전송:

if filters:
    for key, value in filters.items():
        url += f"&{key}={value}"  # ❌ No URL encoding

한글, 공백, 특수문자가 포함된 value를 인코딩 없이 전송하면 잘못된 요청이 됩니다.

Solution

표준 라이브러리 urllib.parse.quote를 사용하여 값을 URL 인코딩:

from urllib.parse import quote

if filters:
    for key, value in filters.items():
        url += f"&{key}={quote(str(value), safe='')}"  # ✅ Properly encoded
  • key는 ASCII API 파라미터명이므로 인코딩 불필요
  • valuequote()로 인코딩 (safe='' 옵션으로 모든 특수문자 인코딩)
  • 의존성 추가 불필요 (urllib.parse는 Python 표준 라이브러리)

Quality Gate

  • uv run ruff check . - passed
  • uv run ruff format --check . - passed
  • uv run mypy src - passed
  • uv run pytest tests/unit/providers/lofin/ - 7 passed
  • uv run pytest tests/contract/test_lofin.py - 16 passed

Example

Before:

/api/endpoint?Key=xxx&Type=json&region=서울 강남구

→ 잘못된 요청 (공백과 한글 미인코딩)

After:

/api/endpoint?Key=xxx&Type=json&region=%EC%84%9C%EC%9A%B8%20%EA%B0%95%EB%82%A8%EA%B5%AC

→ 올바른 요청 (URL 인코딩 적용)

Properly encode filter parameter values using urllib.parse.quote to handle Korean characters, spaces, and special characters in API requests. Previously unencoded values could cause malformed requests.

Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-opencode)

Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
@yeongseon yeongseon merged commit 41c6d00 into main Jul 3, 2026
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[K-008][P3] lofin/adapter.py: URL 파라미터 f-string 직접 삽입 — URL 인코딩 미처리

1 participant