Closed
Description
if hugo have markup attribute like the follow
The error is happened as follow
then I edit lib/asciidoctor/cli/options.rb
from
attr = attr.encode UTF_8 unless attr.encoding == UTF_8
to
attr = attr.force_encoding UTF_8 unless attr.encoding == UTF_8
the bug is fixed!
Please reference my fixed to upgrade asciidoctor!
Metadata
Metadata
Assignees
Type
Projects
Milestone
Relationships
Development
No branches or pull requests
Activity
mojavelinux commentedon Sep 8, 2022
An AsciiDoc processor assumes that all input is either UTF-8 encoded or properly labeled. See https://docs.asciidoctor.org/asciidoc/latest/normalization/. It's likely that when Hugo runs the asciidoctor command using the system call, it ends up causing mislabeled data to be passed to Asciidoctor. The proposed change would be reverting the change made for #2764. You can find information about how to relabel the strings in the following comment: #2764 (comment)
Here's what I would be willing to do. We could try .encode and if that fails, fall back to force_encoding. In other words:
Can you try that logic and see if it works for you?
zkaip commentedon Sep 9, 2022
I solved this problem by modifying the source code, but I hope that this issue can also be updated in the main asciidoctor version, because, if the user passes a non-utf_8 string, then compatibility should also be done
mojavelinux commentedon Sep 9, 2022
zkaip commentedon Sep 9, 2022
@mojavelinux you code not worked...
if I changed the code as the follow

then the result is follow

mojavelinux commentedon Sep 9, 2022
Thank you for testing. Let me update the code and I'll get back to you once I have something new to test.
The reason I cannot accept the code as you wrote it is that it would break compatibility with strings that are properly labeled. But I think we can find a way to support both cases.
mojavelinux commentedon Sep 9, 2022
Can you try this code instead? It looks like I had the name of the error class wrong
zkaip commentedon Sep 9, 2022
@mojavelinux Yes, this code resolved the problem.
mojavelinux commentedon Sep 9, 2022
Thanks for verifying! I'll go ahead and proceed with that change.
resolves asciidoctor#4351 force encoding of attribute data passed via…
mojavelinux commentedon Sep 9, 2022
I'll backport this change to 2.0.x as well.
backport fix for #4351 force encoding of attribute data passed via CL…
resolves asciidoctor#4351 force encoding of attribute data passed via…