staticweb makes bad links on python 3
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
OpenStack Object Storage (swift) |
Fix Released
|
Medium
|
Unassigned |
Bug Description
If a prefix used for listings contains non-ASCII characters, static web creates bad links. For example:
$ swift post c -m web-listings:true -r .r:*,.rlistings
$ swift upload c test --object-name ☃/snowman
☃/snowman
$ `swift auth`
$ curl "$OS_STORAGE_
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://
<html>
<head>
<title>Listing of /v1/AUTH_
<style type="text/css">
h1 {font-size: 1em; font-weight: bold;}
th {text-align: left; padding: 0px 1em 0px 1em;}
td {padding: 0px 1em 0px 1em;}
a {text-decoration: none;}
</style>
</head>
<body>
<h1 id="title">Listing of /v1/AUTH_
<table id="listing">
<tr id="heading">
<th class="
<th class="
<th class="
</tr>
<tr id="parent" class="item">
<td class="colname"><a href=".
<td class="
<td class="
</tr>
<tr class="item type-application type-octet-stream">
<td class="colname"><a href="owman"
<td class="
<td class="
</tr>
</table>
</body>
</html>
(Note how the link is to "owman", not "snowman" as expected.)
The trouble (unsurprisingly) comes down to the difference between wsgi and native strings: we get the JSON listing to native strings as we prepare to build the document, but leave the prefix as a WSGI string. As a result, the offsets are off on py3 (where len("☃") == 1 but len(str_
Reviewed: https:/ /review. opendev. org/750062 /git.openstack. org/cgit/ openstack/ swift/commit/ ?id=ba46eb0e3d7 832924da98ca84e aad40e37c75516
Committed: https:/
Submitter: Zuul
Branch: master
commit ba46eb0e3d78329 24da98ca84eaad4 0e37c75516
Author: Tim Burke <email address hidden>
Date: Fri Sep 4 22:47:54 2020 -0700
py3: Fix non-ascii chars in staticweb listings
Change-Id: Ifcf810f009a803 6f250a09eec0d9a 65a77342129
Closes-Bug: #1894357