{"action":"opened","number":300,"pull_request":{"url":"https://api.github.com/repos/apache/trafficserver/pulls/300","id":46750525,"html_url":"https://github.com/apache/trafficserver/pull/300","diff_url":"https://github.com/apache/trafficserver/pull/300.diff","patch_url":"https://github.com/apache/trafficserver/pull/300.patch","issue_url":"https://api.github.com/repos/apache/trafficserver/issues/300","number":300,"state":"open","locked":false,"title":"TS-3956: Header_rewrite applies strange logic with = operator","user":{"login":"bgaff","id":947865,"avatar_url":"https://avatars.githubusercontent.com/u/947865?v=3","gravatar_id":"","url":"https://api.github.com/users/bgaff","html_url":"https://github.com/bgaff","followers_url":"https://api.github.com/users/bgaff/followers","following_url":"https://api.github.com/users/bgaff/following{/other_user}","gists_url":"https://api.github.com/users/bgaff/gists{/gist_id}","starred_url":"https://api.github.com/users/bgaff/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bgaff/subscriptions","organizations_url":"https://api.github.com/users/bgaff/orgs","repos_url":"https://api.github.com/users/bgaff/repos","events_url":"https://api.github.com/users/bgaff/events{/privacy}","received_events_url":"https://api.github.com/users/bgaff/received_events","type":"User","site_admin":false},"body":"Please see ticket TS-3956 for more information, I'm using github here so that @zwoop / @jacksontj can provide a code review.\r\n\r\nIt appears that whitespace causes weird behavior with header_rewrite, for example:\r\nIf you remove the white space before the = and the quotes it appears to behave correctly. This whitespace issue is likely to cause strange bugs and needs to be fixed.\r\n\r\n```\r\ncond %{READ_REQUEST_HDR_HOOK}\r\ncond %{CLIENT-HEADER:Host} /^localhost$/ [AND]\r\ncond %{CLIENT-HEADER:non_existent_header} = \"shouldnt_exist_anyway\" [AND]\r\nadd-header X-HeaderRewriteApplied true\r\n```\r\nWith the following request:\r\n\r\n```\r\ncurl -v localhost/\r\n```\r\n\r\nHeader_rewrite will incorrectly apply the rule:\r\n\r\n```\r\n[Oct  4 20:56:49.245] Server {0x7ffff61b5700} DIAG: (header_rewrite) Building resources, hook=TS_HTTP_READ_REQUEST_HDR_HOOK\r\n[Oct  4 20:56:49.245] Server {0x7ffff61b5700} DIAG: (header_rewrite) \tAdding TXN client request header buffers\r\n[Oct  4 20:56:49.245] Server {0x7ffff61b5700} DIAG: (header_rewrite) Getting Header: Host, field_loc: 0x7fffd02070d0\r\n[Oct  4 20:56:49.245] Server {0x7ffff61b5700} DIAG: (header_rewrite) Appending HEADER(Host) to evaluation value -> localhost\r\n[Oct  4 20:56:49.245] Server {0x7ffff61b5700} DIAG: (header_rewrite) Test regular expression ^localhost$ : localhost\r\n[Oct  4 20:56:49.245] Server {0x7ffff61b5700} DIAG: (header_rewrite) Successfully found regular expression match\r\n[Oct  4 20:56:49.245] Server {0x7ffff61b5700} DIAG: (header_rewrite) Evaluating HEADER(): localhost - rval: 1\r\n[Oct  4 20:56:49.245] Server {0x7ffff61b5700} DIAG: (header_rewrite) Getting Header: non_existent_header, field_loc: (nil)\r\n[Oct  4 20:56:49.245] Server {0x7ffff61b5700} DIAG: (header_rewrite) Evaluating HEADER():  - rval: 1\r\n[Oct  4 20:56:49.245] Server {0x7ffff61b5700} DIAG: (header_rewrite) OperatorAddHeader::exec() invoked on header X-HeaderRewriteApplied: true\r\n[Oct  4 20:56:49.245] Server {0x7ffff61b5700} DIAG: (header_rewrite)    Adding header X-HeaderRewriteApplied\r\n```\r\nI have a proposed patch incoming it maintains backwards compatability while being a little more flexible with whitespace, for example the following config will parse as:\r\n\r\n```\r\ncond %{READ_REQUEST_HDR_HOOK}\r\ncond %{CLIENT-HEADER:Host} /^localhost$/            [AND]\r\n   cond %{CLIENT-HEADER:Host}    =a\r\n     # COMMENT!\r\n# COMMENT\r\n   cond %{Client-HEADER:Foo} =b\r\n   cond %{Client-HEADER:Blah}       =        x\r\ncond %{CLIENT-HEADER:non_existent_header} =  \"shouldnt_   exist    _anyway\"          [AND]\r\ncond %{CLIENT-HEADER:non_existent_header} =  \"shouldnt_   =    _anyway\"          [AND]\r\ncond %{CLIENT-HEADER:non_existent_header} =\"=\"          [AND]\r\ncond %{CLIENT-HEADER:non_existent_header} =\"\"          [AND]\r\nadd-header X-HeaderRewriteApplied true\r\n```\r\n\r\n```\r\n$1 = std::vector of length 2, capacity 2 = {\"cond\", \"%{READ_REQUEST_HDR_HOOK}\"}\r\n$2 = std::vector of length 4, capacity 4 = {\"cond\", \"%{CLIENT-HEADER:Host}\", \"/^localhost$/\", \"[AND]\"}\r\n$3 = std::vector of length 4, capacity 4 = {\"cond\", \"%{CLIENT-HEADER:Host}\", \"=\", \"a\"}\r\n$4 = std::vector of length 4, capacity 4 = {\"cond\", \"%{Client-HEADER:Foo}\", \"=\", \"b\"}\r\n$5 = std::vector of length 4, capacity 4 = {\"cond\", \"%{Client-HEADER:Blah}\", \"=\", \"x\"}\r\n$6 = std::vector of length 5, capacity 8 = {\"cond\", \"%{CLIENT-HEADER:non_existent_header}\", \"=\", \"shouldnt_   exist    _anyway\", \"[AND]\"}\r\n$7 = std::vector of length 5, capacity 8 = {\"cond\", \"%{CLIENT-HEADER:non_existent_header}\", \"=\", \"shouldnt_   =    _anyway\", \"[AND]\"}\r\n$8 = std::vector of length 5, capacity 8 = {\"cond\", \"%{CLIENT-HEADER:non_existent_header}\", \"=\", \"=\", \"[AND]\"}\r\n$9 = std::vector of length 5, capacity 8 = {\"cond\", \"%{CLIENT-HEADER:non_existent_header}\", \"=\", \"\", \"[AND]\"}\r\n$10 = std::vector of length 3, capacity 4 = {\"add-header\", \"X-HeaderRewriteApplied\", \"true\"}\r\n```","created_at":"2015-10-05T07:27:10Z","updated_at":"2015-10-05T07:27:10Z","closed_at":null,"merged_at":null,"merge_commit_sha":null,"assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/apache/trafficserver/pulls/300/commits","review_comments_url":"https://api.github.com/repos/apache/trafficserver/pulls/300/comments","review_comment_url":"https://api.github.com/repos/apache/trafficserver/pulls/comments{/number}","comments_url":"https://api.github.com/repos/apache/trafficserver/issues/300/comments","statuses_url":"https://api.github.com/repos/apache/trafficserver/statuses/bd3f2a8a3da46b0a4c59c5cb1a2509be9b02c0dd","head":{"label":"bgaff:master","ref":"master","sha":"bd3f2a8a3da46b0a4c59c5cb1a2509be9b02c0dd","user":{"login":"bgaff","id":947865,"avatar_url":"https://avatars.githubusercontent.com/u/947865?v=3","gravatar_id":"","url":"https://api.github.com/users/bgaff","html_url":"https://github.com/bgaff","followers_url":"https://api.github.com/users/bgaff/followers","following_url":"https://api.github.com/users/bgaff/following{/other_user}","gists_url":"https://api.github.com/users/bgaff/gists{/gist_id}","starred_url":"https://api.github.com/users/bgaff/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bgaff/subscriptions","organizations_url":"https://api.github.com/users/bgaff/orgs","repos_url":"https://api.github.com/users/bgaff/repos","events_url":"https://api.github.com/users/bgaff/events{/privacy}","received_events_url":"https://api.github.com/users/bgaff/received_events","type":"User","site_admin":false},"repo":{"id":39371263,"name":"trafficserver","full_name":"bgaff/trafficserver","owner":{"login":"bgaff","id":947865,"avatar_url":"https://avatars.githubusercontent.com/u/947865?v=3","gravatar_id":"","url":"https://api.github.com/users/bgaff","html_url":"https://github.com/bgaff","followers_url":"https://api.github.com/users/bgaff/followers","following_url":"https://api.github.com/users/bgaff/following{/other_user}","gists_url":"https://api.github.com/users/bgaff/gists{/gist_id}","starred_url":"https://api.github.com/users/bgaff/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bgaff/subscriptions","organizations_url":"https://api.github.com/users/bgaff/orgs","repos_url":"https://api.github.com/users/bgaff/repos","events_url":"https://api.github.com/users/bgaff/events{/privacy}","received_events_url":"https://api.github.com/users/bgaff/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/bgaff/trafficserver","description":"Mirror of Apache Traffic Server","fork":true,"url":"https://api.github.com/repos/bgaff/trafficserver","forks_url":"https://api.github.com/repos/bgaff/trafficserver/forks","keys_url":"https://api.github.com/repos/bgaff/trafficserver/keys{/key_id}","collaborators_url":"https://api.github.com/repos/bgaff/trafficserver/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/bgaff/trafficserver/teams","hooks_url":"https://api.github.com/repos/bgaff/trafficserver/hooks","issue_events_url":"https://api.github.com/repos/bgaff/trafficserver/issues/events{/number}","events_url":"https://api.github.com/repos/bgaff/trafficserver/events","assignees_url":"https://api.github.com/repos/bgaff/trafficserver/assignees{/user}","branches_url":"https://api.github.com/repos/bgaff/trafficserver/branches{/branch}","tags_url":"https://api.github.com/repos/bgaff/trafficserver/tags","blobs_url":"https://api.github.com/repos/bgaff/trafficserver/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/bgaff/trafficserver/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/bgaff/trafficserver/git/refs{/sha}","trees_url":"https://api.github.com/repos/bgaff/trafficserver/git/trees{/sha}","statuses_url":"https://api.github.com/repos/bgaff/trafficserver/statuses/{sha}","languages_url":"https://api.github.com/repos/bgaff/trafficserver/languages","stargazers_url":"https://api.github.com/repos/bgaff/trafficserver/stargazers","contributors_url":"https://api.github.com/repos/bgaff/trafficserver/contributors","subscribers_url":"https://api.github.com/repos/bgaff/trafficserver/subscribers","subscription_url":"https://api.github.com/repos/bgaff/trafficserver/subscription","commits_url":"https://api.github.com/repos/bgaff/trafficserver/commits{/sha}","git_commits_url":"https://api.github.com/repos/bgaff/trafficserver/git/commits{/sha}","comments_url":"https://api.github.com/repos/bgaff/trafficserver/comments{/number}","issue_comment_url":"https://api.github.com/repos/bgaff/trafficserver/issues/comments{/number}","contents_url":"https://api.github.com/repos/bgaff/trafficserver/contents/{+path}","compare_url":"https://api.github.com/repos/bgaff/trafficserver/compare/{base}...{head}","merges_url":"https://api.github.com/repos/bgaff/trafficserver/merges","archive_url":"https://api.github.com/repos/bgaff/trafficserver/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/bgaff/trafficserver/downloads","issues_url":"https://api.github.com/repos/bgaff/trafficserver/issues{/number}","pulls_url":"https://api.github.com/repos/bgaff/trafficserver/pulls{/number}","milestones_url":"https://api.github.com/repos/bgaff/trafficserver/milestones{/number}","notifications_url":"https://api.github.com/repos/bgaff/trafficserver/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/bgaff/trafficserver/labels{/name}","releases_url":"https://api.github.com/repos/bgaff/trafficserver/releases{/id}","created_at":"2015-07-20T08:11:30Z","updated_at":"2015-07-20T08:11:36Z","pushed_at":"2015-10-05T07:23:55Z","git_url":"git://github.com/bgaff/trafficserver.git","ssh_url":"git@github.com:bgaff/trafficserver.git","clone_url":"https://github.com/bgaff/trafficserver.git","svn_url":"https://github.com/bgaff/trafficserver","homepage":null,"size":48254,"stargazers_count":0,"watchers_count":0,"language":"C++","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"apache:master","ref":"master","sha":"840fd32635ae670e9234f1a1dc1b914ad6b7945a","user":{"login":"apache","id":47359,"avatar_url":"https://avatars.githubusercontent.com/u/47359?v=3","gravatar_id":"","url":"https://api.github.com/users/apache","html_url":"https://github.com/apache","followers_url":"https://api.github.com/users/apache/followers","following_url":"https://api.github.com/users/apache/following{/other_user}","gists_url":"https://api.github.com/users/apache/gists{/gist_id}","starred_url":"https://api.github.com/users/apache/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/apache/subscriptions","organizations_url":"https://api.github.com/users/apache/orgs","repos_url":"https://api.github.com/users/apache/repos","events_url":"https://api.github.com/users/apache/events{/privacy}","received_events_url":"https://api.github.com/users/apache/received_events","type":"Organization","site_admin":false},"repo":{"id":356066,"name":"trafficserver","full_name":"apache/trafficserver","owner":{"login":"apache","id":47359,"avatar_url":"https://avatars.githubusercontent.com/u/47359?v=3","gravatar_id":"","url":"https://api.github.com/users/apache","html_url":"https://github.com/apache","followers_url":"https://api.github.com/users/apache/followers","following_url":"https://api.github.com/users/apache/following{/other_user}","gists_url":"https://api.github.com/users/apache/gists{/gist_id}","starred_url":"https://api.github.com/users/apache/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/apache/subscriptions","organizations_url":"https://api.github.com/users/apache/orgs","repos_url":"https://api.github.com/users/apache/repos","events_url":"https://api.github.com/users/apache/events{/privacy}","received_events_url":"https://api.github.com/users/apache/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/apache/trafficserver","description":"Mirror of Apache Traffic Server","fork":false,"url":"https://api.github.com/repos/apache/trafficserver","forks_url":"https://api.github.com/repos/apache/trafficserver/forks","keys_url":"https://api.github.com/repos/apache/trafficserver/keys{/key_id}","collaborators_url":"https://api.github.com/repos/apache/trafficserver/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/apache/trafficserver/teams","hooks_url":"https://api.github.com/repos/apache/trafficserver/hooks","issue_events_url":"https://api.github.com/repos/apache/trafficserver/issues/events{/number}","events_url":"https://api.github.com/repos/apache/trafficserver/events","assignees_url":"https://api.github.com/repos/apache/trafficserver/assignees{/user}","branches_url":"https://api.github.com/repos/apache/trafficserver/branches{/branch}","tags_url":"https://api.github.com/repos/apache/trafficserver/tags","blobs_url":"https://api.github.com/repos/apache/trafficserver/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/apache/trafficserver/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/apache/trafficserver/git/refs{/sha}","trees_url":"https://api.github.com/repos/apache/trafficserver/git/trees{/sha}","statuses_url":"https://api.github.com/repos/apache/trafficserver/statuses/{sha}","languages_url":"https://api.github.com/repos/apache/trafficserver/languages","stargazers_url":"https://api.github.com/repos/apache/trafficserver/stargazers","contributors_url":"https://api.github.com/repos/apache/trafficserver/contributors","subscribers_url":"https://api.github.com/repos/apache/trafficserver/subscribers","subscription_url":"https://api.github.com/repos/apache/trafficserver/subscription","commits_url":"https://api.github.com/repos/apache/trafficserver/commits{/sha}","git_commits_url":"https://api.github.com/repos/apache/trafficserver/git/commits{/sha}","comments_url":"https://api.github.com/repos/apache/trafficserver/comments{/number}","issue_comment_url":"https://api.github.com/repos/apache/trafficserver/issues/comments{/number}","contents_url":"https://api.github.com/repos/apache/trafficserver/contents/{+path}","compare_url":"https://api.github.com/repos/apache/trafficserver/compare/{base}...{head}","merges_url":"https://api.github.com/repos/apache/trafficserver/merges","archive_url":"https://api.github.com/repos/apache/trafficserver/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/apache/trafficserver/downloads","issues_url":"https://api.github.com/repos/apache/trafficserver/issues{/number}","pulls_url":"https://api.github.com/repos/apache/trafficserver/pulls{/number}","milestones_url":"https://api.github.com/repos/apache/trafficserver/milestones{/number}","notifications_url":"https://api.github.com/repos/apache/trafficserver/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/apache/trafficserver/labels{/name}","releases_url":"https://api.github.com/repos/apache/trafficserver/releases{/id}","created_at":"2009-10-31T08:00:10Z","updated_at":"2015-09-30T10:56:07Z","pushed_at":"2015-10-04T17:45:05Z","git_url":"git://github.com/apache/trafficserver.git","ssh_url":"git@github.com:apache/trafficserver.git","clone_url":"https://github.com/apache/trafficserver.git","svn_url":"https://github.com/apache/trafficserver","homepage":null,"size":72302,"stargazers_count":322,"watchers_count":322,"language":"C++","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":226,"mirror_url":"git://git.apache.org/trafficserver.git","open_issues_count":16,"forks":226,"open_issues":16,"watchers":322,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/apache/trafficserver/pulls/300"},"html":{"href":"https://github.com/apache/trafficserver/pull/300"},"issue":{"href":"https://api.github.com/repos/apache/trafficserver/issues/300"},"comments":{"href":"https://api.github.com/repos/apache/trafficserver/issues/300/comments"},"review_comments":{"href":"https://api.github.com/repos/apache/trafficserver/pulls/300/comments"},"review_comment":{"href":"https://api.github.com/repos/apache/trafficserver/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/apache/trafficserver/pulls/300/commits"},"statuses":{"href":"https://api.github.com/repos/apache/trafficserver/statuses/bd3f2a8a3da46b0a4c59c5cb1a2509be9b02c0dd"}},"merged":false,"mergeable":null,"mergeable_state":"unknown","merged_by":null,"comments":0,"review_comments":0,"commits":1,"additions":87,"deletions":51,"changed_files":1}}