This is an automated email from the ASF dual-hosted git repository.

fanningpj pushed a commit to branch 1.0.x
in repository https://gitbox.apache.org/repos/asf/pekko-http.git


The following commit(s) were added to refs/heads/1.0.x by this push:
     new eb43f5558 fix parse broken when header value is null (#575) (#581)
eb43f5558 is described below

commit eb43f5558769904436c904144702871c764184c4
Author: PJ Fanning <[email protected]>
AuthorDate: Fri Jul 19 18:47:15 2024 +0100

    fix parse broken when header value is null (#575) (#581)
    
    * fix parse broken when header value is null
    
    * fix style
    
    * revert not need change
    
    * improve match case
    
    * revert HttpHeader and update  HeaderParser.failure
    
    * update assert
    
    ---------
    
    Co-authored-by: Laglangyue <[email protected]>
    Co-authored-by: tangjiafu <[email protected]>
---
 .../org/apache/pekko/http/impl/model/parser/HeaderParser.scala     | 5 +++--
 .../org/apache/pekko/http/impl/model/parser/HttpHeaderSpec.scala   | 7 +++++++
 2 files changed, 10 insertions(+), 2 deletions(-)

diff --git 
a/http-core/src/main/scala/org/apache/pekko/http/impl/model/parser/HeaderParser.scala
 
b/http-core/src/main/scala/org/apache/pekko/http/impl/model/parser/HeaderParser.scala
index 6b7bd7029..68ae18e63 100644
--- 
a/http-core/src/main/scala/org/apache/pekko/http/impl/model/parser/HeaderParser.scala
+++ 
b/http-core/src/main/scala/org/apache/pekko/http/impl/model/parser/HeaderParser.scala
@@ -86,8 +86,9 @@ private[http] class HeaderParser(
   def failure(error: Throwable): HeaderParser.Failure =
     HeaderParser.Failure {
       error match {
-        case IllegalUriException(info) => info
-        case NonFatal(e)               => 
ErrorInfo.fromCompoundString(e.getMessage)
+        case IllegalUriException(info)           => info
+        case NonFatal(e) if e.getMessage == null => 
ErrorInfo.fromCompoundString(e.toString)
+        case NonFatal(e)                         => 
ErrorInfo.fromCompoundString(e.getMessage)
       }
     }
   def ruleNotFound(ruleName: String): Result = HeaderParser.RuleNotFound
diff --git 
a/http-core/src/test/scala/org/apache/pekko/http/impl/model/parser/HttpHeaderSpec.scala
 
b/http-core/src/test/scala/org/apache/pekko/http/impl/model/parser/HttpHeaderSpec.scala
index 651277f43..1e9dcba50 100644
--- 
a/http-core/src/test/scala/org/apache/pekko/http/impl/model/parser/HttpHeaderSpec.scala
+++ 
b/http-core/src/test/scala/org/apache/pekko/http/impl/model/parser/HttpHeaderSpec.scala
@@ -876,6 +876,13 @@ class HttpHeaderSpec extends AnyFreeSpec with Matchers {
       parse("User-Agent", "(" * 10000).errors.head shouldEqual
       ErrorInfo("Illegal HTTP header 'User-Agent': Illegal header value", 
"Header comment nested too deeply")
     }
+
+    "should not broken when header-value is null" in {
+      val errors = parse("Content-Disposition", null).errors
+      errors should have size 1
+      errors.head shouldBe an[ErrorInfo]
+    }
+
   }
 
   implicit class TestLine(line: String) {


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

Reply via email to