nikhil1511 opened a new issue, #1515:
URL: https://github.com/apache/poi/issues/1515

   ### Description
   
   In `VBAMacroReader.processDirStream`, `PROJECT_CODEPAGE` resolves the 
project charset via:
   
   ```java
   modules.charset = Charset.forName(CodePageUtil.codepageToEncoding(codepage, 
true));
   ```
   
   When a VBA project contains a non-standard or unmapped code page (for 
example, `10025`, where `CodePageUtil` returns `"cp10025"` and 
`Charset.forName` throws `UnsupportedCharsetException`) or `0` (where 
`CodePageUtil.codepageToEncoding` throws `UnsupportedEncodingException`), 
`processDirStream` catches the exception and rethrows `IOException("Error 
occurred while reading macros at section id 3 (0x0003)", e)`, aborting 
extraction of all modules in the file—even when the `dir` record layout and 
module streams are structurally valid, or when running on a minimal JVM image 
without `jdk.charsets`.
   
   ### Specification and POI precedent
   
   - [MS-OVBA 2.3.4.2.1.5 (PROJECTCODEPAGE 
Record)](https://learn.microsoft.com/en-us/openspecs/office_file_formats/ms-ovba/bd134afb-1cbd-4ceb-8b11-bfa822455655)
 defines no fallback, while [MS-OVBA 
2.3.4.3](https://learn.microsoft.com/en-us/openspecs/office_file_formats/ms-ovba/c66b58a6-f8ba-4141-9382-0612abce9926)
 and [MS-OVBA 1.1 
Glossary](https://learn.microsoft.com/en-us/openspecs/office_file_formats/ms-ovba/7610371f-e282-4319-87c4-d5602373aaea)
 define VBA module text as MBCS (1- or 2-byte Windows code pages).
   - `VBAMacroReader.ModuleMap` already initializes `Charset charset = 
WIN_1252;` as the default when `PROJECTCODEPAGE` is absent.
   - Every `dir` record carries explicit byte lengths, so decoding MBCS strings 
with `windows-1252` does not affect record framing.
   - Elsewhere in POI, HSMF `MAPIMessage` and HPSF `Property` log a warning and 
continue when encountering an unsupported code page.
   
   ### Expected behavior
   
   Log a warning and retain `WIN_1252` (`windows-1252`) when `PROJECT_CODEPAGE` 
cannot be resolved by `CodePageUtil` or `Charset.forName`, allowing macro 
extraction to proceed.
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to