Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

In HtmlRenderer, escape_html() returns a string with encoding #<Encoding:ASCII-8BIT> #130

Closed
andreas12345 opened this issue Feb 1, 2021 · 1 comment · Fixed by #133
Closed

Comments

@andreas12345
Copy link

Hi,

when trying to override HtmlRenderer#text, I noticed that the encoding of the string after escape_html() is #Encoding:ASCII-8BIT:

  def text(node)
    puts node.string_content.encoding.inspect # prints #<Encoding:UTF-8>
    puts escape_html(node.string_content).encoding.inspect # prints #<Encoding:ASCII-8BIT>
  end

A workaround I used was to apply force_encoding('utf-8') before continuing processing of the string.

  • Andreas
@kivikakk
Copy link
Collaborator

kivikakk commented Feb 1, 2021

Thanks for reporting this! That's a good find. We should probably propagate the encoding of rb_text here:

if (houdini_escape_html0(&buf, (const uint8_t *)RSTRING_PTR(rb_text),
RSTRING_LEN(rb_text), 0)) {
result = (char *)cmark_strbuf_detach(&buf);
return rb_str_new2(result);
}

(and in a few other places around there.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants