Skip to content

fix: 합쳐진 이중모음(ㅘ 등)을 중성으로 받으면 잘못된 문자를 반환하는 문제 수정 - #407

Open
yubin121 wants to merge 2 commits into
toss:mainfrom
yubin121:fix/combine-character-double-vowel
Open

yubin121 wants to merge 2 commits into
toss:mainfrom
yubin121:fix/combine-character-double-vowel

Conversation

@yubin121

@yubin121 yubin121 commented Oct 8, 2026 •

Copy link
Copy Markdown

Overview

combineCharacter에 'ㅘ'처럼 합쳐진 이중모음을 중성으로 전달하면, 에러 없이 다른 문자를 반환하는 문제를 수정합니다.

// as-is
combineCharacter('ㄱ', 'ㅘ');       // 'ꯤ' (U+ABE4, 한글이 아닌 문자)
combineCharacter('ㅎ', 'ㅘ');       // '피'
combineCharacter('ㅇ', 'ㅢ');       // '씨'
combineCharacter('ㅇ', 'ㅘ', 'ㄴ'); // '씬'

// to-be
combineCharacter('ㄱ', 'ㅘ');       // '과'
combineCharacter('ㅎ', 'ㅘ');       // '화'
combineCharacter('ㅇ', 'ㅢ');       // '의'
combineCharacter('ㅇ', 'ㅘ', 'ㄴ'); // '완'

합쳐진 이중모음(ㅘ ㅙ ㅚ ㅝ ㅞ ㅟ ㅢ)이 들어가는 조합 3,724개(초성 19 × 이중모음 7 × 종성 28)가 모두 잘못된 결과를 반환합니다. 초성이 ㄱ이면 한글이 아닌 문자가 나오고, 나머지 초성에서는 다른 한글 글자가 나와 결과만 보고는 알아채기 어렵습니다.

원인

#333 이후 canBeJungseong('ㅘ')가 true를 반환해 입력 검증은 통과하지만, 인덱스를 찾는 JUNGSEONGS에는 이중모음이 'ㅗㅏ' 같은 분해형으로만 들어 있어 indexOf가 -1을 반환합니다. 중성 인덱스가 -1로 계산되어 결과가 앞 초성에 중성 ㅣ가 붙은 글자가 되고(예: ㅎ → 피), 앞 초성이 없는 ㄱ은 한글 범위를 벗어납니다.

#333 이전 커밋에서는 같은 입력에 Invalid hangul Characters 에러가 발생했으므로 회귀에 해당합니다.

수정

인덱스를 찾기 전에 DISASSEMBLED_VOWELS_BY_VOWEL로 합쳐진 모음을 분해형으로 변환합니다. 단모음은 자기 자신으로, 분해형은 그대로 통과하므로 기존 입력의 동작은 바뀌지 않습니다.

테스트

  • 이중모음 7개 합성, 합쳐진 모음과 분해형의 결과 일치 케이스 추가
  • 수정 전·후 빌드를 비교해 기존 동작 유지 확인

PR Checklist

  • I read and included theses actions below
  1. I have read the Contributing Guide
  2. I have written documents and tests, if needed.

@yubin121
yubin121 requested a review from raon0211 as a code owner October 8, 2026 06:47
@changeset-bot

changeset-bot Bot commented Oct 8, 2026 •

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 5320aa2

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
es-hangul Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@vercel

vercel Bot commented Oct 8, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
es-hangul Error Error Nov 5, 2026 2:17pm UTC

Request Review

@yubin121 yubin121 changed the title fix: 합쳐진 이중모음(ㅘ 등)을 중성으로 받으면 한글이 아닌 문자를 반환하는 문제 수정 fix: 합쳐진 이중모음(ㅘ 등)을 중성으로 받으면 잘못된 문자를 반환하는 문제 수정 Nov 4, 2026

This branch had an error being deployed

1 failed deployment
Preview — 5320aa2b Deployed Nov 5, 2026 by vercel[bot]
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.

1 participant