Jump to content
mklement0

Dictionary > Define a word functionality fails to open the relevant page in Dictionary.app when the search term includes an apostrophe [Fixed 4.0.3 b1091 pre-release]

Recommended Posts

E.g., searching for "Dunbar's number" correctly shows the preview of the Dictionary.app article, but submitting the entry in order to display it in Dictionary.app quietly fails - a blank page is shown.

 

Omitting the apostrophe (single quote) - searching for "Dunbar number" - works as expected.

 

Share this post


Link to post
Share on other sites

@mklement0 interesting spot, thanks!

 

It looks like a bug in Dictionary.app as if I type the following into Terminal, I get the same:

open "dict://dunbar's number"

The best I think I can do to fix this in Alfred is to strip single quotes from the input - I'll do this in the next build :) 

 

Cheers,

Andrew

Share this post


Link to post
Share on other sites
23 minutes ago, Andrew said:

open "dict://dunbar's number"

 

This works fine, though (on High Sierra): open 'dict://dunbar%27s%20number'

 

Look like you just need to properly encode the URL.

Share this post


Link to post
Share on other sites
2 hours ago, deanishe said:

This works fine, though (on High Sierra): open 'dict://dunbar%27s%20number'

 

I can confirm it also works on Mojave.


But here’s something interesting. In both Alfred and dict://, dunbar's number (straight quote) fails, but dunbar’s number (curly quote) works.

Share this post


Link to post
Share on other sites

Weird. Perhaps some dodgy heuristics in open when figuring out whether/what to URL encode?

 

I've seen it do weird stuff before with URLs that aren't properly escaped. Sometimes they work, sometimes they don't.

 

Share this post


Link to post
Share on other sites

Alfred uses [NSURL URLWithString:urlString]; and single quote is considered valid in a query so isn't escaped, returning the URL "dict://dunbar's%20number", so this is a bug in Dictionary.

 

Interestingly, Alfred has a custom fallback encoder which encodes lots more (including single quote) if URLWithString fails. If Dictionary is failing to read a fully encoded URL, it makes me nervous to pass a fully encoded string as it may do something opposite.

Share this post


Link to post
Share on other sites
19 minutes ago, Andrew said:

If Dictionary is failing to read a fully encoded URL

 

The URL isn't fully encoded, though. Apostrophe is a reserved character, so it should be encoded here. It appears to be a known issue with Apple's URL-encoding routines.

Share this post


Link to post
Share on other sites
3 hours ago, deanishe said:

The URL isn't fully encoded

 

I meant fully encoded NSURL... i.e. Apple's own encoding being read by Apple's own Dictionary app.

Share this post


Link to post
Share on other sites

Okie smokie, fiddling around a bit more and I'm going to fix this properly in the next build rather than just removing the single quote :) 

Share this post


Link to post
Share on other sites

×
×
  • Create New...