Page MenuHomePhabricator

Fix "arc paste" to stop creating pastes with an empty string ("") as the "language"
ClosedPublic

Authored by epriestley on May 9 2018, 5:56 PM.
Tags
None
Referenced Files
Unknown Object (File)
Tue, Nov 19, 2:28 AM
Unknown Object (File)
Fri, Nov 15, 1:37 PM
Unknown Object (File)
Sun, Nov 10, 5:30 PM
Unknown Object (File)
Thu, Nov 7, 4:39 AM
Unknown Object (File)
Sat, Oct 26, 5:11 AM
Unknown Object (File)
Oct 9 2024, 9:34 AM
Unknown Object (File)
Sep 30 2024, 10:23 PM
Unknown Object (File)
Sep 26 2024, 11:49 PM
Subscribers
None

Details

Summary

See PHI652. When you echo x | arc paste today, you end up with a Paste object that has the empty string as its "language".

This is normally not valid. Pastes where the language should be autodetected should have the value null, not the empty string.

This behavior likely changed when paste.create got rewritten in terms of paste.edit. Adjust the implementation so it only adds the LANGUAGE transaction if there's an actual language.

Also, fix an issue where you can't use the "delete" key to delete tokens with the empty string as their value.

Test Plan
  • Created a paste with echo x | arc paste, got a paste in autodetect mode instead of with a bogus language value.
  • Created a paste with echo x | arc paste --lang rainbow, got a rainbow paste.
  • Deleted an empty string token with the keyboard.
  • Deleted normal tokens with the keyboard.
  • Edited subscribers/etc normally with the keyboard and mouse to make sure I didn't ruin anything.

Diff Detail

Repository
rP Phabricator
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

amckinley added inline comments.
src/applications/paste/conduit/PasteCreateConduitAPIMethod.php
70

Add an empty string check to PhabricatorPasteLanguageTransaction->validateTransactions()?

This revision is now accepted and ready to land.May 9 2018, 8:04 PM

Add an empty string check

I was thinking this would break stuff, but I think I was a little muddled and that it's actually safe. Gimmie a sec..

  • Validate that language is null or nonempty string.
  • Edited a paste to autodetect/empty/null, and to a real language like "XML".
  • Hit the error by manually crafting a Conduit request.
This revision was automatically updated to reflect the committed changes.