(command.CommandList children: [ (command.Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (lhs_expr.LhsName name:test_description) op: Equal rhs: { (SQ <'gitweb as standalone script (parsing script output).\n'> <'\n'> <'This test runs gitweb (git web interface) as a CGI script from the\n'> <'commandline, and checks that it produces the correct output, either\n'> <'in the HTTP header or the actual script output.'> ) } ) ] ) (C {(.)} {(./gitweb-lib.sh)}) (command.SimpleCommand words: [{(cat)}] redirects: [ (redir.Redir op:<Redir_DGreat '>>'> fd:16777215 arg_word:{(gitweb_config.perl)}) (redir.HereDoc op: <Redir_DLess '<<'> fd: 16777215 here_begin: {(word_part.EscapedLiteralPart token:<Lit_EscapedChar '\\E'>) (OF)} here_end_span_id: 54 stdin_parts: [ ('\n') ("$known_snapshot_formats{'tar'} = {\n") ("\t'display' => 'tar',\n") ("\t'type' => 'application/x-tar',\n") ("\t'suffix' => '.tar',\n") ("\t'format' => 'tar',\n") ('};\n') ('\n') ("$feature{'snapshot'}{'default'} = ['tar'];\n") ] ) ] ) (command.FuncDef name: check_snapshot body: (command.BraceGroup children: [ (command.Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (lhs_expr.LhsName name:basename) op: Equal rhs: {($ VSub_Number '$1')} ) ] ) (command.Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (lhs_expr.LhsName name:prefix) op: Equal rhs: { (word_part.BracedVarSub token: <VSub_Number 2> suffix_op: (suffix_op.StringUnary op_id: VTest_ColonHyphen arg_word: {(DQ ($ VSub_Number '$1'))} ) ) } ) ] ) (C {(echo)} {(DQ ('basename=') ($ VSub_DollarName '$basename'))}) (command.AndOr ops: [Op_DAmp Op_DAmp] children: [ (command.SimpleCommand words: [ {(grep)} {(DQ ('filename=.*') ($ VSub_DollarName '$basename') (.tar))} {(gitweb.headers)} ] redirects: [ (redir.Redir op: <Redir_Great '>'> fd: 16777215 arg_word: {(/dev/null)} ) (redir.Redir op:<Redir_GreatAnd '2>&'> fd:2 arg_word:{(1)}) ] ) (command.SimpleCommand words: [{(DQ ($ VSub_DollarName '$TAR'))} {(tf)} {(gitweb.body)}] redirects: [(redir.Redir op:<Redir_Great '>'> fd:16777215 arg_word:{(file_list)})] ) (command.Pipeline children: [ (C {(grep)} {(-v)} {(-e)} {(DQ ('^') ($ VSub_DollarName '$prefix') (Lit_Other '$'))} {(-e)} {(DQ ('^') ($ VSub_DollarName '$prefix') (/))} {(-e)} {(DQ ('^pax_global_header') (Lit_Other '$'))} {(file_list)} ) ] negated: T ) ] ) ] ) ) (C {(test_expect_success)} {(setup)} { (SQ <'\n'> <'\ttest_commit first foo &&\n'> <'\tgit branch xx/test &&\n'> <'\tFULL_ID=$(git rev-parse --verify HEAD) &&\n'> <'\tSHORT_ID=$(git rev-parse --verify --short=7 HEAD)\n'> ) } ) (C {(test_debug)} {(SQ <'\n'> <'\techo "FULL_ID = $FULL_ID"\n'> <'\techo "SHORT_ID = $SHORT_ID"\n'>)} ) (C {(test_expect_success)} {(SQ <'snapshot: full sha1'>)} { (SQ <'\n'> <'\tgitweb_run "p=.git;a=snapshot;h=$FULL_ID;sf=tar" &&\n'> <'\tcheck_snapshot ".git-$SHORT_ID"\n'> ) } ) (C {(test_debug)} {(SQ <'cat gitweb.headers && cat file_list'>)}) (C {(test_expect_success)} {(SQ <'snapshot: shortened sha1'>)} { (SQ <'\n'> <'\tgitweb_run "p=.git;a=snapshot;h=$SHORT_ID;sf=tar" &&\n'> <'\tcheck_snapshot ".git-$SHORT_ID"\n'> ) } ) (C {(test_debug)} {(SQ <'cat gitweb.headers && cat file_list'>)}) (C {(test_expect_success)} {(SQ <'snapshot: almost full sha1'>)} { (SQ <'\n'> <'\tID=$(git rev-parse --short=30 HEAD) &&\n'> <'\tgitweb_run "p=.git;a=snapshot;h=$ID;sf=tar" &&\n'> <'\tcheck_snapshot ".git-$SHORT_ID"\n'> ) } ) (C {(test_debug)} {(SQ <'cat gitweb.headers && cat file_list'>)}) (C {(test_expect_success)} {(SQ <'snapshot: HEAD'>)} { (SQ <'\n'> <'\tgitweb_run "p=.git;a=snapshot;h=HEAD;sf=tar" &&\n'> <'\tcheck_snapshot ".git-HEAD-$SHORT_ID"\n'> ) } ) (C {(test_debug)} {(SQ <'cat gitweb.headers && cat file_list'>)}) (C {(test_expect_success)} {(SQ <'snapshot: short branch name (master)'>)} { (SQ <'\n'> <'\tgitweb_run "p=.git;a=snapshot;h=master;sf=tar" &&\n'> <'\tID=$(git rev-parse --verify --short=7 master) &&\n'> <'\tcheck_snapshot ".git-master-$ID"\n'> ) } ) (C {(test_debug)} {(SQ <'cat gitweb.headers && cat file_list'>)}) (C {(test_expect_success)} {(SQ <'snapshot: short tag name (first)'>)} { (SQ <'\n'> <'\tgitweb_run "p=.git;a=snapshot;h=first;sf=tar" &&\n'> <'\tID=$(git rev-parse --verify --short=7 first) &&\n'> <'\tcheck_snapshot ".git-first-$ID"\n'> ) } ) (C {(test_debug)} {(SQ <'cat gitweb.headers && cat file_list'>)}) (C {(test_expect_success)} {(SQ <'snapshot: full branch name (refs/heads/master)'>)} { (SQ <'\n'> <'\tgitweb_run "p=.git;a=snapshot;h=refs/heads/master;sf=tar" &&\n'> <'\tID=$(git rev-parse --verify --short=7 master) &&\n'> <'\tcheck_snapshot ".git-master-$ID"\n'> ) } ) (C {(test_debug)} {(SQ <'cat gitweb.headers && cat file_list'>)}) (C {(test_expect_success)} {(SQ <'snapshot: full tag name (refs/tags/first)'>)} { (SQ <'\n'> <'\tgitweb_run "p=.git;a=snapshot;h=refs/tags/first;sf=tar" &&\n'> <'\tcheck_snapshot ".git-first"\n'> ) } ) (C {(test_debug)} {(SQ <'cat gitweb.headers && cat file_list'>)}) (C {(test_expect_success)} {(SQ <'snapshot: hierarchical branch name (xx/test)'>)} { (SQ <'\n'> <'\tgitweb_run "p=.git;a=snapshot;h=xx/test;sf=tar" &&\n'> <'\t! grep "filename=.*/" gitweb.headers\n'> ) } ) (C {(test_debug)} {(SQ <'cat gitweb.headers'>)}) (C {(test_expect_success)} {(SQ <'forks: setup'>)} { (SQ <'\n'> <'\tgit init --bare foo.git &&\n'> <'\techo file > file &&\n'> <'\tgit --git-dir=foo.git --work-tree=. add file &&\n'> <'\tgit --git-dir=foo.git --work-tree=. commit -m "Initial commit" &&\n'> <'\techo "foo" > foo.git/description &&\n'> <'\tgit clone --bare foo.git foo.bar.git &&\n'> <'\techo "foo.bar" > foo.bar.git/description &&\n'> <'\tgit clone --bare foo.git foo_baz.git &&\n'> <'\techo "foo_baz" > foo_baz.git/description &&\n'> <'\trm -fr foo &&\n'> <'\tmkdir -p foo &&\n'> <'\t(\n'> <'\t\tcd foo &&\n'> <'\t\tgit clone --shared --bare ../foo.git foo-forked.git &&\n'> <'\t\techo "fork of foo" > foo-forked.git/description\n'> <'\t)\n'> ) } ) (C {(test_expect_success)} {(SQ <'forks: not skipped unless "forks" feature enabled'>)} { (SQ <'\n'> <'\tgitweb_run "a=project_list" &&\n'> <'\tgrep -q ">\\\\.git<" gitweb.body &&\n'> <'\tgrep -q ">foo\\\\.git<" gitweb.body &&\n'> <'\tgrep -q ">foo_baz\\\\.git<" gitweb.body &&\n'> <'\tgrep -q ">foo\\\\.bar\\\\.git<" gitweb.body &&\n'> <'\tgrep -q ">foo_baz\\\\.git<" gitweb.body &&\n'> <'\tgrep -q ">foo/foo-forked\\\\.git<" gitweb.body &&\n'> <'\tgrep -q ">fork of .*<" gitweb.body\n'> ) } ) (C {(test_expect_success)} {(SQ <'enable forks feature'>)} { (SQ <'\n'> <'\tcat >>gitweb_config.perl <<-\\EOF\n'> <'\t$feature{"forks"}{"default"} = [1];\n'> <'\tEOF\n'> ) } ) (C {(test_expect_success)} {(SQ <'forks: forks skipped if "forks" feature enabled'>)} { (SQ <'\n'> <'\tgitweb_run "a=project_list" &&\n'> <'\tgrep -q ">\\\\.git<" gitweb.body &&\n'> <'\tgrep -q ">foo\\\\.git<" gitweb.body &&\n'> <'\tgrep -q ">foo_baz\\\\.git<" gitweb.body &&\n'> <'\tgrep -q ">foo\\\\.bar\\\\.git<" gitweb.body &&\n'> <'\tgrep -q ">foo_baz\\\\.git<" gitweb.body &&\n'> <'\tgrep -v ">foo/foo-forked\\\\.git<" gitweb.body &&\n'> <'\tgrep -v ">fork of .*<" gitweb.body\n'> ) } ) (C {(test_expect_success)} {(SQ <'forks: "forks" action for forked repository'>)} { (SQ <'\n'> <'\tgitweb_run "p=foo.git;a=forks" &&\n'> <'\tgrep -q ">foo/foo-forked\\\\.git<" gitweb.body &&\n'> <'\tgrep -q ">fork of foo<" gitweb.body\n'> ) } ) (C {(test_expect_success)} {(SQ <'forks: can access forked repository'>)} { (SQ <'\n'> <'\tgitweb_run "p=foo/foo-forked.git;a=summary" &&\n'> <'\tgrep -q "200 OK" gitweb.headers &&\n'> <'\tgrep -q ">fork of foo<" gitweb.body\n'> ) } ) (C {(test_expect_success)} {(SQ <'forks: project_index lists all projects (incl. forks)'>)} { (SQ <'\n'> <'\tcat >expected <<-\\EOF &&\n'> <'\t.git\n'> <'\tfoo.bar.git\n'> <'\tfoo.git\n'> <'\tfoo/foo-forked.git\n'> <'\tfoo_baz.git\n'> <'\tEOF\n'> <'\tgitweb_run "a=project_index" &&\n'> <'\tsed -e "s/ .*//" <gitweb.body | sort >actual &&\n'> <'\ttest_cmp expected actual\n'> ) } ) (command.FuncDef name: xss body: (command.BraceGroup children: [ (command.AndOr ops: [Op_DAmp Op_DAmp] children: [ (command.SimpleCommand words: [{(echo)} {(DQ ('Checking ') ($ VSub_Number '$1') (...))}] redirects: [(redir.Redir op:<Redir_GreatAnd '>&'> fd:16777215 arg_word:{(2)})] ) (C {(gitweb_run)} {(DQ ($ VSub_Number '$1'))}) (command.If arms: [ (if_arm cond: [ (command.Sentence child: (C {(grep)} {(DQ ($ VSub_DollarName '$TAG'))} {(gitweb.body)}) terminator: <Op_Semi ';'> ) ] action: [ (command.SimpleCommand words: [ {(echo)} { (DQ ('xss: ') ($ VSub_DollarName '$TAG') (' should have been quoted in output') ) } ] redirects: [(redir.Redir op:<Redir_GreatAnd '>&'> fd:16777215 arg_word:{(2)})] ) (command.ControlFlow token: <ControlFlow_Return return> arg_word: {(1)} ) ] ) ] ) ] ) (command.ControlFlow token:<ControlFlow_Return return> arg_word:{(0)}) ] ) ) (C {(test_expect_success)} {(SQ <'xss checks'>)} { (SQ <'\n'> <'\tTAG="<magic-xss-tag>" &&\n'> <'\txss "a=rss&p=$TAG" &&\n'> <'\txss "a=rss&p=foo.git&f=$TAG"\n'> ) } ) (C {(test_done)}) ] )