Skip to content
This repository has been archived by the owner. It is now read-only.

@Model.XXX will throw Argument encoder does not implement MaxOutputCharsPerInputChar correctly #3465

Closed
yukozh opened this issue Nov 3, 2015 · 12 comments

Comments

Projects
None yet
6 participants
@yukozh
Copy link
Contributor

commented Nov 3, 2015

      An unhandled exception has occurred: Argument encoder does not implement MaxOutputCharsPerInputChar correctly.
      System.ArgumentException: Argument encoder does not implement MaxOutputCharsPerInputChar correctly.
         在 System.Text.Encodings.Web.TextEncoder.EncodeCore(TextWriter output, Char* value, Int32 valueLength)
         在 System.Text.Encodings.Web.TextEncoder.Encode(TextWriter output, String value, Int32 startIndex, Int32 charac
terCount)
         在 Microsoft.AspNet.Mvc.Razor.RazorPage.WriteTo(TextWriter writer, HtmlEncoder encoder, Object value, Boolean e
scapeQuotes)
         在 Microsoft.AspNet.Mvc.Razor.RazorPage.WriteTo(TextWriter writer, Object value)
         在 Microsoft.AspNet.Mvc.Razor.RazorPage.Write(Object value)
         在 Asp.ASPV__Views_Status_Show_cshtml.<ExecuteAsync>d__33.MoveNext() 位置 /Views/Status/Show.cshtml:行号 76

@yukozh yukozh changed the title @Model.XXX will throw Argument encoder does not implement MaxOutputCharsPerInputChar correctly when the content is too long @Model.XXX will throw Argument encoder does not implement MaxOutputCharsPerInputChar correctly Nov 3, 2015

@Eilon

This comment has been minimized.

Copy link
Member

commented Nov 3, 2015

@kagamine using which version of MVC + DNX?

@Tratcher maybe related to your change?

@yukozh

This comment has been minimized.

Copy link
Contributor Author

commented Nov 3, 2015

The rc2 latest. If your string contains an unknown encoding character, it will throw this.
I think use a ? to replace the unknown character is better.

@davidfowl

This comment has been minimized.

Copy link
Member

commented Nov 3, 2015

@yukozh

This comment has been minimized.

Copy link
Contributor Author

commented Nov 5, 2015

I think throw an exception is dangerous. When you developed a blog, someone submit a comment with the unknown encoding char to some post, your site will crash down. @Eilon @davidfowl

@davidfowl

This comment has been minimized.

Copy link
Member

commented Nov 5, 2015

If an exception thrown because of user input in a text box can crash your site then you have bigger problems

@Eilon

This comment has been minimized.

Copy link
Member

commented Nov 9, 2015

@Tratcher can you do a quick initial investigation?

@yukozh

This comment has been minimized.

Copy link
Contributor Author

commented Nov 9, 2015

Should I write a repro? @Eilon

@Tratcher

This comment has been minimized.

Copy link
Member

commented Nov 9, 2015

That would help. Preferably something that calls html encoder directly.

@Tratcher

This comment has been minimized.

Copy link
Member

commented Nov 9, 2015

At the very least it would be good to know what the text was that failed.

@cesarbs

This comment has been minimized.

Copy link
Contributor

commented Nov 11, 2015

This looks like a bug in corefx, I've filed an issue: dotnet/corefx#4455. Notice the repro is really simple.

@Tratcher Tratcher closed this Nov 11, 2015

@dougbu

This comment has been minimized.

Copy link
Member

commented Nov 12, 2015

Why file a CoreFx issue about a bug seen when using Mono? Or is this actually a problem when using .NET core?

@yukozh

This comment has been minimized.

Copy link
Contributor Author

commented Nov 12, 2015

This occurred with System.Text.Encodings.Web

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
You can’t perform that action at this time.