[Webkit-unassigned] [Bug 258195] New: Service Worker: Redirect loses hash fragment

bugzilla-daemon at webkit.org bugzilla-daemon at webkit.org
Fri Jun 16 02:56:58 PDT 2023


https://bugs.webkit.org/show_bug.cgi?id=258195

            Bug ID: 258195
           Summary: Service Worker: Redirect loses hash fragment
           Product: WebKit
           Version: Safari 16
          Hardware: Unspecified
                OS: Unspecified
            Status: NEW
          Severity: Normal
          Priority: P2
         Component: Service Workers
          Assignee: webkit-unassigned at lists.webkit.org
          Reporter: webkit at lauritz-holtmann.de

Hi there!

Apparently Webkit has a comparable issue to: https://bugzilla.mozilla.org/show_bug.cgi?id=1420672

Redirects which include hash fragments and that are intercepted by Service Workers lose their fragment.


## Proof of concept

register_worker.html
```html
<script>
if ("serviceWorker" in navigator) {
  navigator.serviceWorker.register("/sw.js")
}
```

sw.js
```javascript
self.addEventListener("fetch", (event) => {
  console.log("fetch event");
  event.respondWith(fetch(event.request));
});
```

/index.php
```php
<?php
    header('Location: /test.html',true,301);
    exit();
```

test.html
```javascript
<script>alert(window.location)</script>
```

### Steps to reproduce
1. Browse /index.php#test => Observe that redirect keeps fragment as expected
2. Browse /register_worker.html to Register Service worker
3. Browse /index.php#test => Observe that redirect lose fragment

-- 
You are receiving this mail because:
You are the assignee for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.webkit.org/pipermail/webkit-unassigned/attachments/20230616/e81a45c6/attachment-0001.htm>


More information about the webkit-unassigned mailing list