Restore ViewCVS 0.9.x behavior when "checkout_magic" option is disabled

so disabling it doesn't break compatibility with old log URLs.

Add new "default_file_view" option so people who won't miss the old log
URLs can view static HTML sites in ViewVC without using checkout_magic.

Also, deprecate the "checkout_magic" option and make it disabled by
default. Don't want that last part to get lost, so I'll repeat:

  =================================================================
   WARNING: This commit changes the default "checkout_magic" value
  =================================================================

Reasons for disabling "checkout_magic" by default include the security
hole it leaves for people trying to do URL authorization and its general
ugliness. People who actually use "checkout_magic" for the static HTML
browsing should prefer the "default_file_view" syntax now that it
is available. And people who really need "checkout_magic" for the
compatibility with ViewCVS 0.9.x log URLs can easily enable it.

* lib/viewvc.py
  (Request.run_viewvc, Request.get_link):
     handle "checkout_magic" and "default_file_view" options

* lib/config.py
* viewvc.conf.dist
    add "default_file_view" option and disable "checkout_magic" by default

* CHANGES
* viewvc.org/upgrading.html
* viewvc.org/url-reference.html
    update documentation


git-svn-id: http://viewvc.tigris.org/svn/viewvc/trunk@1311 8cb11bc2-c004-0410-86c3-e597b4017df7
remotes/tags/1.0.0-rc1
rey4 2006-04-04 03:11:02 +00:00
parent 93e802daf4
commit c195eb1e46
6 changed files with 50 additions and 45 deletions

11
CHANGES
View File

@ -30,13 +30,10 @@ Version 1.0 (not yet released)
port (2005-Dec-22)
* make "default_root" option optional. When no root is specified,
show a page listing all available repositories (2005-Feb-04)
* make "checkout_magic" obsolete (but still enabled by default for
URL compatibility with old versions of ViewCVS). When disabled,
bare file URLs (with no query parameters) will return checked
out file contents instead of log listings. That way, checkout
URLs no longer need magic /*checkout*/ strings in them for
relative links and image paths in checked out HTML files to work
(2005-Feb-13)
* add "default_file_view" option to make it possible for relative
links and image paths in checked out HTML files to work without
the need for special /*checkout*/ prefixes in URLs. Deprecate
"checkout_magic" option and disable by default (2006-Apr-03)
* hide CVS "Attic" directories and add simple toggle for showing
dead files in directory listings (2004-Jul-31)
* show Unified, Context and Side-by-side diffs in HTML instead of

View File

@ -179,6 +179,8 @@ class Config:
self.cvsdb.rss_row_limit = 100
self.options.root_as_url_component = 0
self.options.default_file_view = "log"
self.options.checkout_magic = 0
self.options.sort_by = 'file'
self.options.sort_group_dirs = 1
self.options.hide_attic = 1
@ -193,7 +195,6 @@ class Config:
self.options.allow_annotate = 1
self.options.allow_markup = 1
self.options.allow_compress = 1
self.options.checkout_magic = 1
self.options.template_dir = "templates"
self.options.docroot = None
self.options.show_subdir_lastmod = 0

View File

@ -353,16 +353,13 @@ class Request:
else:
self.view_func = view_cvsgraph_image
elif self.query_dict.has_key('revision') \
or not cfg.options.checkout_magic:
# if checkout_magic is disabled the default view is view_checkout
# so relative links inside checked out files will work
or cfg.options.default_file_view != "log":
if self.query_dict.get('content-type', None) in (viewcvs_mime_type,
alt_mime_type):
self.view_func = view_markup
else:
self.view_func = view_checkout
else:
# without checkout_magic, the default view for files is view_log
self.view_func = view_log
# if we have a directory and the request didn't end in "/", then redirect
@ -454,13 +451,9 @@ class Request:
url = self.script_name
# no need to explicitly specify checkout view for a file
if view_func is view_checkout and pathtype == vclib.FILE:
view_func = None
# add checkout magic if neccessary
if cfg.options.checkout_magic:
url = url + '/' + checkout_magic_path
# add checkout magic if neccessary
if view_func is view_checkout and cfg.options.checkout_magic:
url = url + '/' + checkout_magic_path
# add root to url
rootname = None
@ -536,6 +529,14 @@ class Request:
and params.get('r2') is not None):
view_func = None
# no need to explicitly specify checkout view when it's the default
# view, when checkout_magic is enabled, or when "revision" is present
if view_func is view_checkout:
if ((cfg.options.default_file_view != "log" and pathtype == vclib.FILE)
or cfg.options.checkout_magic
or params.get('revision') is not None):
view_func = None
view_code = _view_codes.get(view_func)
if view_code and not (params.has_key('view') and params['view'] is None):
params['view'] = view_code

View File

@ -256,26 +256,31 @@ languages = en-us
#---------------------------------------------------------------------------
[options]
### DOC
# root_as_url_component: Interpret the first path component in the URL
# after the script location as the root to use. This is an
# alternative to using the "root=" query key. If ViewVC is configured
# with multiple repositories, this results in more natural looking
# ViewVC URLs and allows you to browse checked out HTML files with
# relative links to other repository files within ViewVC.
# ViewVC URLs.
# Note: Enabling this option will break backwards compatibility with
# any old ViewVC URL which doesn't have an explicit "root" parameter.
# any old ViewCVS URL which doesn't have an explicit "root" parameter.
root_as_url_component = 0
# checkout_magic: Generate checkout links with a magic *checkout* prefix.
# This option is enabled for backwards compatibility with URLs used by old
# versions of ViewVC. If you disable it, old *checkout* URLs will continue
# to work, but old log page urls which don't have explicit "view=log"
# parameters will load checkout pages instead. It is recommended that you
# disable this option in a fresh viewvc installation, or if you don't need
# to support old-style log URLs.
checkout_magic = 1
# default_file_view: "log" or "co"
# Controls whether the default view for file URLs is a checkout view or
# a log view. "log" is the default for backwards compatibility with old
# ViewCVS URLs, but "co" has the advantage that it allows ViewVC to serve
# static HTML pages directly from a repository with working links
# to other repository files
# Note: Changing this option may cause old ViewCVS URLs that referred
# to log pages to load checkout pages instead.
default_file_view = log
# checkout_magic: Use checkout links with magic /*checkout*/ prefixes so
# checked out HTML pages can have working links to other repository files
# Note: This option is DEPRECATED and should not be used in new ViewVC
# installations. Setting "default_file_view = co" achieves the same effect
checkout_magic = 0
# http_expiration_time: Expiration time (in seconds) for cacheable
# pages served by ViewVC. Note that in most cases, a cache aware

View File

@ -100,19 +100,19 @@
is also possible to enable a backwards compatibility mode by
setting <code>utc_time = 0</code> at the top of lib/dbi.py</p>
<h3>URL Compatibility</h3>
<h3>"checkout_magic" Option</h3>
<p>In it's default configuration ViewVC 1.0 will continue to work with
bookmarks and links from old versions of ViewVC, ViewCVS, and
CVSWeb. But if you change options that affect the URL scheme, this
may no longer hold true. In particular, if you enable the
<var>root_as_url_component</var> option, old viewcvs URLs that
don't specify an explicit root with the <var>root</var> parameter
will not work. Likewise, if you disable the
<var>checkout_magic</var> option, old URLs that that pointed to log
pages and don't have explicit <var>view=log</var> parameters will
load checkout pages instead.
</p>
<p>In ViewVC 1.0, the <code>checkout_magic</code> option has been
disabled by default to provide a simpler URL scheme that works
safely with URL authorization. Most users will not notice any
difference in behavior, but users who had been using ViewCVS to
browse the contents of static HTML pages stored in a repository
may notice that links and images in those pages targetted at other
files in the repository no longer display correctly. The new
<code>default_file_view</code> option can be used to solve this
problem and, if neccessary, <code>checkout_magic</code> can also
be re-enabled. The <code>viewcvs.conf</code> file describes these
options in detail.</p>
<h3>Configuration Options</h3>
@ -128,6 +128,7 @@
<li>options/http_expiration_time</li>
<li>options/generate_etags</li>
<li>options/root_as_url_component</li>
<li>options/default_file_view</li>
<li>options/sort_group_dirs</li>
<li>options/use_pagesize</li>
<li>options/limit_changes</li>

View File

@ -282,7 +282,7 @@ th.caption {
<tr>
<td><code>view=co</code></td>
<td>depends</td>
<td><a href="#view-param"><code>view</code> parameter</a>, not needed if the <code>checkout_magic</code> configuration variable is disabled since that makes the checkout view the default view for file paths. Also not needed if the <code>/*checkout*</code> magic prefix or the <code>revision</code> parameter is present.
<td><a href="#view-param"><code>view</code> parameter</a>, not needed if the <code>default_file_view</code> configuration variable is set to <code>co</code>, since that makes the checkout view the default view for file paths. Also not needed if the <code>/*checkout*</code> magic prefix or the <code>revision</code> parameter is present.
</tr>
<tr>
<td><code>content-type=<var>TYPE</var></code></td>
@ -637,7 +637,7 @@ th.caption {
<tr>
<td><code>view=log</code></td>
<td>depends</td>
<td><a href="#view-param"><code>view</code> parameter</a>, does not need to be specified for file paths when the <code>checkout_magic</code> configuration option is enabled</td>
<td><a href="#view-param"><code>view</code> parameter</a>, does not need to be specified for file paths when the <code>default_file_view</code> configuration option is set to <code>log</code>. However it is recommended that the parameter be passed anyway for consistency with directory log URLs and compatibility with ViewVC installations that set <code>default_file_view</code> to <code>co</code>.</td>
</tr>
<tr>
<td><code>logsort=<var>SORT</var></code></td>