diff options
author | Maksymilian Osowski <maxosowski@google.com> | 2010-09-01 04:08:36 -0700 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2010-09-01 04:08:36 -0700 |
commit | 0791b1868c46ccb65512ac34b0fc06c43759eda9 (patch) | |
tree | 34e799095c70e77c631e7b00358cc28f9582f9a7 /WebKitTools/DumpRenderTree/android/view_source.php | |
parent | f3874afeed62195d72e27a3f9a4b85767a5df631 (diff) | |
parent | f5929f20b546de2c377c9ae2be2f3d0054f1b3e0 (diff) | |
download | external_webkit-0791b1868c46ccb65512ac34b0fc06c43759eda9.zip external_webkit-0791b1868c46ccb65512ac34b0fc06c43759eda9.tar.gz external_webkit-0791b1868c46ccb65512ac34b0fc06c43759eda9.tar.bz2 |
Merge "Added script to show the source of the test."
Diffstat (limited to 'WebKitTools/DumpRenderTree/android/view_source.php')
-rw-r--r-- | WebKitTools/DumpRenderTree/android/view_source.php | 53 |
1 files changed, 53 insertions, 0 deletions
diff --git a/WebKitTools/DumpRenderTree/android/view_source.php b/WebKitTools/DumpRenderTree/android/view_source.php new file mode 100644 index 0000000..dfe6d12 --- /dev/null +++ b/WebKitTools/DumpRenderTree/android/view_source.php @@ -0,0 +1,53 @@ +<?php +# Copyright (C) 2010 The Android Open Source Project +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +############################################################################### + +# Show the source of the test. +# +# Usage: +# view_source.php?src=PATH +# where +# PATH - relative path in the LayoutTests dir + + # Global variables + # The server document root is LayoutTests/http/tests. See run_apache2.py. + $rootDir = realpath($_SERVER['DOCUMENT_ROOT'] . '..' . DIRECTORY_SEPARATOR . '..'); + + function getAbsolutePath($relPath) { + global $rootDir; + return $rootDir . DIRECTORY_SEPARATOR . $relPath; + } + + function main() { + global $rootDir; + + # Very primitive check if path tries to go above DOCUMENT_ROOT or is absolute + if (strpos($_GET['src'], "..") !== False || + substr($_GET['src'], 0, 1) == DIRECTORY_SEPARATOR) { + return; + } + + #If we don't want realpath to append any prefixes we need to pass it an absolute path + $src = realpath(getAbsolutePath($_GET['src'])); + + echo "<html><body>"; + # TODO: Add link following and syntax highlighting for html and js. + echo highlight_string(file_get_contents($src)); + echo "</body></html>"; + } + + main(); +?> |