1. Daryl Foster
  2. PowerBuilder
  3. Wednesday, 19 January 2022 05:40 AM UTC

Hi, I'm having a small issue with the browser control in PB2019R3 (Build 2728).  I think it might be a bug, but wanted to check if there is any way around it.

We use the browser control to display local files, so we navigate using a windows filepath. If the filename contains a # character the file isn't found.

E.g. If I use this command:

wb_browser.Navigate('C:\temp\Invoice#1.pdf')

The browser control displays the error:

Page failed to load.
URL:file:///C:/temp/Invoice#1.pdf
Error: File not found. (-6)

If I do a similar thing in Chrome (or Edge or Firefox) and navigate to a local filepath, it will automatically urlencode it and use the file:// protocol.  Is the browser control able to do a similar thing?

e.g. at the moment I navigate to

C:\temp\Invoice#1.pdf

and the browser control tries (and fails) to display

file:///C:/temp/Invoice#1.pdf

But if I do the same thing from Chrome the browser will display

file:///C:/temp/Invoice%231.pdf

i.e. it urlencodes the # character in the filepath.

 

 

René Ullrich Accepted Answer Pending Moderation
  1. Wednesday, 19 January 2022 06:35 AM UTC
  2. PowerBuilder
  3. # 1

The # symbol is a special character in a URL to jump to an anchor in a page. So the browser takes as filename only "Invoice".

It is up to you to urlencode the filename and/or directory names of the path. The browser control can't know whether # should be part of the filename or a anchor reference. Use URLEncode function of Coderobject.

Keep in mind: You can't encode the full path, only parts!!!

lnv_coderobject.UrlEncode (Blob("file:///C:/temp/Invoice#1.pdf", EncodingUTF8!)) will return file%3A%2F%2F%2FC%3A%2Ftemp%2FInvoice%231.pdf because it encodes all special characters, also ":" and "/")

HTH,

René

Comment
  1. John Fauss
  2. Wednesday, 19 January 2022 14:59 PM UTC
There's a subtle distinction between the underlying technology used by the PB Web Browser control and how it interfaces with the user. Yes, the Web Browser control, the Chrome and Edge browser apps all use the Chromium "engine", but each utilizes its own unique user interface. There are going to be differences when comparing how the user interface of the PB Web Browser control works to any stand-alone browser application.

The user interface in Chrome and Edge (and Firefox as well as others) handles the URLEncode'ing before handing the URL off to the content retrieval part of the browser. Since the PB Web Browser control does not supply a navigation "single-line edit" control, you'll need to perform this encoding. This sounds like an excellent enhancement request, by the way.
  1. Helpful
  1. Daryl Foster
  2. Thursday, 20 January 2022 02:06 AM UTC
Thanks John, I agree it would be a good enhancement request. I still think it should work that way already though. For Chrome and Firefox I enter C:\temp\Invoice#1.pdf and the browser automagically redirects it to file:///C:/temp/Invoice%231.pdf. But for the web browser control when I give it C:\temp\Invoice#1.pdf it automagically redirects it to file:///C:/temp/Invoice#1.pdf. So the web browser control must have some internal process to transform a local filepath to a file url. That process should do the url encoding. It's only the # character that cause an issue, most of the other special characters still seem to work without urlencoding.
  1. Helpful
  1. Miguel Leeuwe
  2. Thursday, 20 January 2022 08:28 AM UTC
Based on other tickets I've seen, Appeon is looking at the latest version of the CEF implementation. Cross fingers this problem will be resolved.
  1. Helpful
There are no comments made yet.
  • Page :
  • 1


There are no replies made for this question yet.
However, you are not allowed to reply to this question.