diff --git a/r2c.py b/r2c.py index 991c8f5..39b5ee0 100644 --- a/r2c.py +++ b/r2c.py @@ -51,6 +51,8 @@ def read_dxf_bytes(raw): current['section'] = section if current: records.append(current) + if not records or records[-1]['type'] != 'EOF' or records[-1]['tags']: + raise ValueError('DXF 종료 표시(EOF)가 없습니다. 파일이 끝까지 저장되었는지 확인해 주세요.') entities = [r for r in records if r['section'] == 'ENTITIES'] blocks, block = {}, None for record in records: diff --git a/tests/test_r2c.py b/tests/test_r2c.py index 507e58b..edec5dc 100644 --- a/tests/test_r2c.py +++ b/tests/test_r2c.py @@ -216,6 +216,14 @@ class DrawingReconstructionTests(unittest.TestCase): with self.assertRaisesRegex(ValueError, '관로 단면'): r2c.specification_model(self.model, row) + def test_upload_rejects_dxf_missing_end_marker(self): + lines = self.raw.splitlines(keepends=True) + self.assertEqual(lines[-1].strip(), b'EOF') + truncated = b''.join(lines[:-2]) + status, payload = self.api_request(truncated) + self.assertEqual(status, 422) + self.assertIn('EOF', payload['error']) + def test_spline_validation_and_valid_linear_interpolation(self): def spline(weights=('1', '1'), knots=('0', '0', '1', '1'), degree='1'): return {'type': 'SPLINE', 'tags': [