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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "note-connector",
3
- "version": "0.2.8",
3
+ "version": "0.2.9",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
package/py/pyproject.toml CHANGED
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "note-connector"
3
- version = "0.2.8"
3
+ version = "0.2.9"
4
4
  description = "note-connector: MCP server and ChatGPT connector for note.com"
5
5
  readme = "README.md"
6
6
  requires-python = ">=3.13"
@@ -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
- if not clean.strip():
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
- return base64.b64decode(clean, validate=True)
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,