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 26, 6:35 PM
Unknown Object (File)
Mon, Nov 25, 3:42 AM
Unknown Object (File)
Sat, Nov 23, 12:13 PM
Unknown Object (File)
Fri, Nov 22, 8:11 AM
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
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
Branch
paste1
Lint
Lint Passed
Unit
Tests Passed
Build Status
Buildable 20299
Build 27559: Run Core Tests
Build 27558: arc lint + arc unit

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.