staticweb makes bad links on python 3

Bug #1894357 reported by Tim Burke
6
This bug affects 1 person
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_URL/c/☃/"
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
 <head>
  <title>Listing of /v1/AUTH_test/c/☃/</title>
  <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_test/c/☃/</h1>
  <table id="listing">
   <tr id="heading">
    <th class="colname">Name</th>
    <th class="colsize">Size</th>
    <th class="coldate">Date</th>
   </tr>
   <tr id="parent" class="item">
    <td class="colname"><a href="../">../</a></td>
    <td class="colsize">&nbsp;</td>
    <td class="coldate">&nbsp;</td>
   </tr>
   <tr class="item type-application type-octet-stream">
    <td class="colname"><a href="owman">owman</a></td>
    <td class="colsize">0</td>
    <td class="coldate">2020-09-05 05:44:31</td>
   </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_to_wsgi("☃")) == 3).

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to swift (master)

Reviewed: https://review.opendev.org/750062
Committed: https://git.openstack.org/cgit/openstack/swift/commit/?id=ba46eb0e3d7832924da98ca84eaad40e37c75516
Submitter: Zuul
Branch: master

commit ba46eb0e3d7832924da98ca84eaad40e37c75516
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: Ifcf810f009a8036f250a09eec0d9a65a77342129
    Closes-Bug: #1894357

Changed in swift:
status: In Progress → Fix Released
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix included in openstack/swift 2.27.0

This issue was fixed in the openstack/swift 2.27.0 release.

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.