Repository navigation
fix(shapes): refuse sizes and corner ratios Hancom reads as 0 - #416
Merged
Merged
Conversation
add_picture wrote any align it was given into hp:pos@horzAlign ("BOGUS",
" RIGHT ", "TOP"), which Hancom reads as LEFT; a non-string failed only after
the image and its paragraph were added. The alignment is now checked first,
in any case, against the schema's horizontal alignments, and anything else is
refused with shape-position-frame before anything is stored.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A negative width or height of a rectangle, ellipse, arc, picture or equation box, or a negative rectangle corner ratio, was written as given; Hancom reads it as 0. Such values, and sizes of 2**31 or more, are now refused with typed errors before any paragraph, run or image is added (shape-size-value, shape-rect-ratio-value). An equation's base_unit outside 1..2**31-1 raises shape-equation-base-unit-value (a ValueError, as before) before its paragraph is added. HwpxOxmlShape.resize refuses a negative size too, and HwpxOxmlParagraph.add_picture builds the picture before adding its run. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This was referenced Oct 6, 2026
add_equation's base unit check now raises a typed error, so oxml/paragraph.py raises one untyped error fewer. The census lock records 202 untyped raises (paragraph.py 18), as the ratchet's self-test expects the lock to match the tree. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
바뀐 점
도형·그림·수식을 넣을 때 음수 크기, 사각형의 음수 모서리 곡률, 수식의 0 이하 기준 크기를 무엇도 더하기 전에 거부한다. 전에는 그대로 썼다.
한/글의 동작
orgSz), 회전 중심, 그림의 이미지 크기(imgDim)도 0이 된다.ratio)도 0으로 읽는다.baseUnit)는 2³¹−1까지 그대로 두고, 저장된 상자 크기로 쪽을 짠다.고치기 전
doc.shapes.add_rectangle(width=-1, height=-1)처럼 음수 크기를 그대로 썼다. 한/글에서는 크기 0인 도형이 된다.base_unit=0은ValueError였다. 다만 퍼사드가 문단을 먼저 더한 뒤라 빈 문단이 남았다.HwpxOxmlParagraph.add_picture는 런을 먼저 더하고 그림 요소를 만들었다. 그래서 그림 요소에서 값이 거부되면 빈 런이 남았다.코드
oxml/shape_position.py에validate_shape_size,validate_rect_ratio,validate_equation_base_unit을 더한다.shape-size-value,shape-rect-ratio-value,shape-equation-base-unit-value다. 셋 다HwpxValueError라서 기준 크기 오류는 전처럼ValueError로도 잡힌다.oxml/objects.py_build_shape_common_children가 크기를 검사하고, 사각형 요소는 곡률을 검사한다.HwpxOxmlShape.resize도 크기를 검사한다.build_at_original_size는 그리는 크기를 검사한다._document/shapes.py,_document/media.py)는 문단이나 그림을 더하기 전에 검사한다. 그림은 크기를 정하고 검사한 뒤에 그림 데이터를 저장한다.HwpxOxmlParagraphadd_picture는 그림 요소를 만든 뒤에 런을 더한다.add_equation은 런을 더하기 전에 기준 크기와 상자를 검사한다.errors.py와docs/error-codes.md에 코드 셋을 등록하고, 변경 로그 항목을 더한다.테스트
tests/test_shape_size_values.py를 더하고, 한/글 저장본 여섯을 함께 넣는다.resize가 음수 크기를 거부하는지이 PR은 #415 위에 쌓았다. #415가 병합되면 그 커밋 둘은 이 PR의 diff에서 빠진다.
🤖 Generated with Claude Code