4

After updating from Safari 13 to Safari 14 (on macOS 10.15.6), I have noticed that all of my text-filtering Automator workflows no longer work correctly when invoked from the updated Safari.

For an example of such a workflow, see the screenshot below. It shows a simple workflow that takes the current text selection, pipes it through the fmt command, and replaces the original selection with that command’s output:

fmt: an example of text-filtering workflow

I have a few workflows of this construction, i.e., consisting of a single Run Shell Script action running a command that takes the text selection on its stdin and outputs the text to replace the selection with on its stdout. I have been using them without any issues for quite a long time (at least, for the last two major releases of macOS).

However, when a workflow like that is run from the newly updated Safari 14, it fails to replace the text selection with the output of the workflow. Instead, it simply deletes the selected text. The issue is clearly specific to Safari 14 only, because the same workflows still work correctly (i.e., replace the selection with the command’s output) in all other apps (e.g., TextEdit).

Is this caused by some security-related novelty in Safari 14 that can be disabled, or is it simply a regression bug that has been introduced in this update? Are there any known workarounds aside from simulating copying and pasting for the command output in Automator workflows?

7
  • 1
    I was just writing a script and debugging it inside of Safari 14, where I'll most likely use the script mainly. I didn't realize that this occurred so thank you for posting the question. A workaround I tested is to add an additional action to copy the output of the workflow to the clipboard and then you can just paste the output back into Safari. Not ideal, but could provide additional functionality if you're okay with having it take up room in your clipboard.
    – cody.codes
    Sep 24, 2020 at 16:39
  • 1
    Yeah, you can even try to trigger a Cmd+V keypress to paste the output from the clipboard via an AppleScript action, but I’m not sure whether it will work. And even then, it would feel very annoying, given that replacement of the selected text had been working perfectly all along through version 13 of Safari. I hope macOS 11 update will fix it. If not, we should report the bug.
    – ib.
    Sep 24, 2020 at 22:20
  • 1
    I also noticed that when my instance of Safari 14 is running for a while, its Safari > Services menu loses track of all the services, showing an empty submenu (“No Services Apply”). So, there are definitely some bugs in Safari 14 that break interoperation with services in general.
    – ib.
    Sep 24, 2020 at 22:26
  • Did you check if the accessibility options under security is enabled for this version? Maybe the system recognizes it as a new program? Sep 30, 2020 at 4:03
  • 1
    @cody.codes: It looks like the bug has been finally fixed in the just-released Safari 14.0.3 (in macOS 11.2), at least in my experience with it! You can go back to your script and perhaps remove whatever workarounds you had to add to it due to the bug.
    – ib.
    Feb 1, 2021 at 22:22

2 Answers 2

0

I am not sure what exactly are you trying to accomplish, but I have an AppleScript code to replace characters and maybe it can be a good way for you to start. This solution works no matter the program because it uses GUI scripting, you just need to select the text and invoke the Service.

As you can see the code is changing all : for /; you can use it to adapt for your needs.

on run {}
    tell application "System Events"
        key code 8 using {command down} -- Cmd+C Copy text to clipboard
        delay 0.1
        set the new_path to (the clipboard as string)
        set save_location to my replace_chars(new_path, ":", "/")
        delay 0.1
        set the clipboard to save_location
        key code 9 using {command down} -- Cmd+V Paste clipboard back
    end tell
end run

on replace_chars(this_text, search_string, replacement_string)
    set AppleScript's text item delimiters to the search_string
    set the item_list to every text item of this_text
    set AppleScript's text item delimiters to the replacement_string
    set this_text to the item_list as string
    set AppleScript's text item delimiters to ""
    return this_text
end replace_chars

Workflow screenshot

0

It is quite obvious at this point that it is indeed a bug. After persisting for several months in Safari versions 14.0, 14.0.1, and 14.0.2, on both macOS Catalina (up to 10.15.7) and Big Sur (up to 11.1), the bug has finally been fixed in Safari 14.0.3 with the release of macOS 11.2 on February 1, 2021.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .