note-connector 0.2.8 → 0.2.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/py/pyproject.toml +1 -1
- package/py/src/note_mcp/api/images.py +18 -2
package/package.json
CHANGED
package/py/pyproject.toml
CHANGED
|
@@ -570,14 +570,30 @@ def _decode_base64_image(image_base64: str) -> bytes:
|
|
|
570
570
|
"""
|
|
571
571
|
clean = _strip_data_url_prefix(image_base64)
|
|
572
572
|
|
|
573
|
-
|
|
573
|
+
# Strip whitespace and newlines (common in ChatGPT output)
|
|
574
|
+
clean = re.sub(r"\s+", "", clean)
|
|
575
|
+
|
|
576
|
+
if not clean:
|
|
574
577
|
raise NoteAPIError(
|
|
575
578
|
code=ErrorCode.INVALID_BASE64,
|
|
576
579
|
message="image_base64 が空です。",
|
|
577
580
|
)
|
|
578
581
|
|
|
582
|
+
# Fix missing padding: base64 length must be a multiple of 4
|
|
583
|
+
# ChatGPT sometimes drops trailing '=' padding chars
|
|
584
|
+
remainder = len(clean) % 4
|
|
585
|
+
if remainder:
|
|
586
|
+
clean += "=" * (4 - remainder)
|
|
587
|
+
|
|
579
588
|
try:
|
|
580
|
-
|
|
589
|
+
# validate=False: tolerate non-strict base64 (extra chars, minor format issues)
|
|
590
|
+
result = base64.b64decode(clean, validate=False)
|
|
591
|
+
if not result:
|
|
592
|
+
raise NoteAPIError(
|
|
593
|
+
code=ErrorCode.INVALID_BASE64,
|
|
594
|
+
message="image_base64 をデコードしましたが、データが空でした。",
|
|
595
|
+
)
|
|
596
|
+
return result
|
|
581
597
|
except (binascii.Error, ValueError) as e:
|
|
582
598
|
raise NoteAPIError(
|
|
583
599
|
code=ErrorCode.INVALID_BASE64,
|