diff options
author | Hong Minhee <minhee@dahlia.kr> | 2012-08-14 00:40:51 +0900 |
---|---|---|
committer | Hong Minhee <minhee@dahlia.kr> | 2012-08-14 00:40:51 +0900 |
commit | ddfda9a7d1210629c7d10d92ac527aec1cc79316 (patch) | |
tree | e67a0efd83a001189c445d8e6a47dd78e7504dea | |
parent | e6bb1ee5b4ebec9fc4c000bf1a25757c3f63ff24 (diff) | |
download | pygments-ddfda9a7d1210629c7d10d92ac527aec1cc79316.tar.gz |
Handle continuous header lines (HttpLexer)
-rw-r--r-- | pygments/lexers/text.py | 6 | ||||
-rw-r--r-- | tests/examplefiles/http_request_example | 3 | ||||
-rw-r--r-- | tests/examplefiles/http_response_example | 6 |
3 files changed, 12 insertions, 3 deletions
diff --git a/pygments/lexers/text.py b/pygments/lexers/text.py index 130ddba9..ec69337c 100644 --- a/pygments/lexers/text.py +++ b/pygments/lexers/text.py @@ -1643,6 +1643,11 @@ class HttpLexer(RegexLexer): yield match.start(5), Literal, match.group(5) yield match.start(6), Text, match.group(6) + def continuous_header_callback(self, match): + yield match.start(1), Text, match.group(1) + yield match.start(2), Literal, match.group(2) + yield match.start(3), Text, match.group(3) + def content_callback(self, match): content_type = getattr(self, 'content_type', None) content = match.group() @@ -1673,6 +1678,7 @@ class HttpLexer(RegexLexer): ], 'headers': [ (r'([^\s:]+)( *)(:)( *)([^\r\n]+)(\r?\n|$)', header_callback), + (r'([\t ]+)([^\r\n]+)(\r?\n|$)', continuous_header_callback), (r'\r?\n', Text, 'content') ], 'content': [ diff --git a/tests/examplefiles/http_request_example b/tests/examplefiles/http_request_example index 5d2a1d52..675d1691 100644 --- a/tests/examplefiles/http_request_example +++ b/tests/examplefiles/http_request_example @@ -3,7 +3,8 @@ Host: pygments.org Connection: keep-alivk
Cache-Control: max-age=0
Origin: http://pygments.org
-User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_7_2) AppleWebKit/535.7 (KHTML, like Gecko) Chrome/16.0.912.63 Safari/535.7
+User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_7_2)
+ AppleWebKit/535.7 (KHTML, like Gecko) Chrome/16.0.912.63 Safari/535.7
Content-Type: application/x-www-form-urlencoded
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Referer: http://pygments.org/
diff --git a/tests/examplefiles/http_response_example b/tests/examplefiles/http_response_example index bf53d61d..51340ca4 100644 --- a/tests/examplefiles/http_response_example +++ b/tests/examplefiles/http_response_example @@ -18,8 +18,10 @@ Expires: Tue, 31 Mar 1981 05:00:00 GMT Cache-Control: no-cache, no-store, must-revalidate, pre-check=0, post-check=0
X-MID: a55f21733bc52bb11d1fc58f9b51b4974fbb8f83
X-RateLimit-Reset: 1323738416
-Set-Cookie: k=10.34.234.116.1323735104238974; path=/; expires=Tue, 20-Dec-11 00:11:44 GMT; domain=.twitter.com
-Set-Cookie: guest_id=v1%3A13237351042425496; domain=.twitter.com; path=/; expires=Thu, 12-Dec-2013 12:11:44 GMT
+Set-Cookie: k=10.34.234.116.1323735104238974; path=/;
+ expires=Tue, 20-Dec-11 00:11:44 GMT; domain=.twitter.com
+Set-Cookie: guest_id=v1%3A13237351042425496; domain=.twitter.com; path=/;
+ expires=Thu, 12-Dec-2013 12:11:44 GMT
Set-Cookie: _twitter_sess=BAh7CDoPY3JlYXRlZF9hdGwrCPS6wjQ0AToHaWQiJTFiMTlhY2E1ZjczYThk%250ANDUwMWQxNjMwZGU2YTQ1ODBhIgpmbGFzaElDOidBY3Rpb25Db250cm9sbGVy%250AOjpGbGFzaDo6Rmxhc2hIYXNoewAGOgpAdXNlZHsA--6b502f30a083e8a41a64f10930e142ea362b1561; domain=.twitter.com; path=/; HttpOnly
Vary: Accept-Encoding
Server: tfe
|