clients icon indicating copy to clipboard operation
clients copied to clipboard

Don't allow to save empty URI

Open 4dfe-9dac opened this issue 3 years ago • 28 comments

The title says it all, don't let people save empty URI.

If empty give them an error before saving it or remove the URI

4dfe-9dac avatar May 14 '21 02:05 4dfe-9dac

I'd love to work on this one.

dmcfaddengalway avatar May 14 '21 20:05 dmcfaddengalway

Go for it @dmcfaddengalway! Please @ me in the PR.

eliykat avatar May 16 '21 21:05 eliykat

@eliykat Thanks!

dmcfaddengalway avatar May 19 '21 17:05 dmcfaddengalway

Hello!

It has been a while since an update in this thread. Would this be okay for me to work on?

f09f909b avatar Dec 17 '21 03:12 f09f909b

Hi, I could work on it @k4awon

enmanuelmag avatar Feb 11 '22 19:02 enmanuelmag

Here is some code to speed up the process.

function main(): void {
    // Check if the string is empty
    console.log(isStringEmpty("Hello World"))
}

main()

// Check if a given string is empty and return a boolean
function isStringEmpty(content: string): boolean {
    return content.length == 0
}

Just do a basic check and if its empty than don't save it.

ghost avatar Feb 12 '22 07:02 ghost

Hey @enmanuelmag I have been busy! You can go for it!

f09f909b avatar Feb 12 '22 07:02 f09f909b

FYI, we have Utils.IsNullOrWhitespace which might be useful here, to save you defining your own method.

eliykat avatar Feb 13 '22 23:02 eliykat

Hi, I've notice the issue remain open. Can i help?

Matheus-BM avatar Apr 30 '22 00:04 Matheus-BM

Hi @Matheus-BM, there hasn't been much activity here so I'd say go for it. However, we're in the middle of reorganizing our repositories (more info here), so I'd recommend waiting a week or so before forking any code. Keep an eye on that Community Forums thread for updates in the meantime.

eliykat avatar May 03 '22 10:05 eliykat

Hi newcomer here, is this possibly up for grabs?

jbeachy21 avatar May 11 '22 19:05 jbeachy21

Hi newcomer here, is this possibly up for grabs?

Hi, I've almost solved the issue, but notice that the project didn't have any error messages attached to the translations that I could show when trying to save empty URI, I was going to request to a new error message, but I were waiting for the migration to the mono repository to end and lost track of time, if you wanna help me open the request for a new string on crowding it would be nice.

Matheus-BM avatar May 11 '22 22:05 Matheus-BM

If you need a new translation string, you can just add it to src/app/locales/en/messages.json, using the format in that file. That's the "base" translation file. It will be automatically synced with CloudIn, and translators will update all other messages.json files.

eliykat avatar May 12 '22 01:05 eliykat

Nice, btw @eliykat one question, if i want to add the solution among other verification like nameRequired in browser\jslib\angular\src\components\add-edit.component.ts which is in jslib repository how should i proceed with the pull request?

Matheus-BM avatar May 13 '22 00:05 Matheus-BM

@Matheus-BM contributions are definitely welcome, however with the repo changes still underway, I think it's probably best to hold off. We intend to migrate web, cli and jslib into this repo (bitwarden/clients) by about 1 June. Then you'll be able to submit a single PR that updates jslib and any client/s at the same time (part of the reason why we're making this change!)

Feel free to still experiment and test things locally during this time - just keep an eye out for when we've finished our migration before submitting a PR.

eliykat avatar May 13 '22 02:05 eliykat

Hi, is anyone working on this issue? I am willing to work on it but having build issues, I see just recently desktop and browser repos have been merged. How to build this project now? Given that there are multiple projects in this repo, I have ran npm i in desktop directory as well but it failed too

If this issue is currently being worked on, point me towards some other one but build errors needs to be tackled first. I am using npm i in the root of this repo and its failing

njmulsqb avatar Jun 11 '22 16:06 njmulsqb

Hi @njmulsqb, I responded to your thread in the Community Forums, but for anyone else also struggling with build steps: check out the build instructions at https://contributing.bitwarden.com/clients/.

Best to wait and see whether @Matheus-BM still wants to work on it. The monorepo transition is complete, so that's no longer an obstacle.

eliykat avatar Jun 13 '22 06:06 eliykat

Hi, @eliykat and @njmulsqb I still want to work on the issue, was just waiting the merge to finish. I probably will submit the pull request later this weekend.

Matheus-BM avatar Jun 13 '22 10:06 Matheus-BM

@njmulsqb if you still looking for a issue to work on, you can have this one, I've solved the issue before mono-repo were done, but now I'm having problems with npm ci , checked instructions but no clue whats happening. Anyway, I no longer want to delay the solving of this issue, if you need the changes I've made I can send it to you.

Matheus-BM avatar Jun 21 '22 21:06 Matheus-BM

Hi @Matheus-BM , Yes sure you can send me the changes you have made and I am ready to work on it. Lately, I am also having build errors when I run npm run electron, here's what the output looks like: https://pastebin.com/eY1tKHn7 Does this seem relevant to the problem you're facing?

njmulsqb avatar Jun 21 '22 23:06 njmulsqb

@Matheus-BM Can you share the changes you made? @eliykat Can you have a look at the pastebin I shared above? I am unable to build desktop app lately, I have taken fresh pull from this repo, npm ci in the root of repo and then npm run electron in desktop directory and its failing. Is it a known issue? How are other devs tackling with this?

njmulsqb avatar Jun 26 '22 14:06 njmulsqb

I've only replaced an old if with this code at line 280 from add-edit.components.ts at libs\angular\src\components\add-edit.component.ts

   for(let i =0; i< this.cipher.login.uris.length ; i++){
   
      if (
        this.cipher.type === CipherType.Login &&
        this.cipher.login.uris != null &&
        (Utils.isNullOrWhitespace(this.cipher.login.uris[i].uri) ) 
      ) {
        this.platformUtilsService.showToast(
          "error",
          this.i18nService.t("errorOccurred"),
          this.i18nService.t("uriEmpty")
        );
        return false;
      }
    }

and added the new error message "uriEmpty" at apps\browser\src\_locales\en\messages.json

 "uriEmpty": {
"message": "URI cannot be empty."}

Matheus-BM avatar Jun 26 '22 15:06 Matheus-BM

As for the electron error on desktop build, not sure its an tracked issue or how to fix it. I've been working on the web extension, but now can't even complete the npm ci because some compatibility issue.

Matheus-BM avatar Jun 26 '22 15:06 Matheus-BM

I can do npm ci but fails at npm run electron. Lets wait for some dev to respond

njmulsqb avatar Jun 26 '22 15:06 njmulsqb

@njmulsqb I'm not sure what's causing that error, unfortunately the output is not very descriptive. Are you on MacOS or Linux?

Some suggestions:

eliykat avatar Jun 30 '22 07:06 eliykat

@eliykat I am on Linux WSL.

Node version is 16.14.2 NPM version is 8.12.2

njmulsqb avatar Jun 30 '22 17:06 njmulsqb

@eliykat I am on Linux WSL.

Node version is 16.14.2 NPM version is 8.12.2

@njmulsqb As you are trying to run npm run electron I'm assuming you are trying to launch the desktop client. A long time ago, I also used WSL2 for my dev environment. The thing with WSL is, that it at time at least, did not come with a window manager. Which is needed to draw/display a window. To overcome this you will need an Xserver. I think I went with VcsXsrv. It did take me a while to get everything setup and it was not very fast so now I do things directly on Win. One less thing to worry about.

@Matheus-BM Not sure what kind of issues you are running into with installing npm packages.

I suggest possibly discussing this further over at https://community.bitwarden.com/t/help-needed-regarding-contributing-to-bitwarden-clients/42004 so we don't spam this issue with setup questions.

djsmith85 avatar Jun 30 '22 18:06 djsmith85

I'd love to pickup this issue if it is no longer being worked on by anyone else.

adradan avatar Sep 07 '22 02:09 adradan

Hello! I'm just curious about the implementation preference for this issue.

The author in the original post suggests two possible solutions: prune empty URIs or issue an error message upon saving. Out of curiosity, which of these two would be your preferred approach, @eliykat?

I see attempts from other collaborators have opted for the latter solution, so you're likely content with that. Though, I'm still interested in hearing a definitive answer on which solution you think is more appropriate.

nick-cd avatar Jan 14 '23 14:01 nick-cd

I personally prefer silently pruning empty URIs upon save. There's no use case for saving an empty URI, so no need to bother the user with an error message in my opinion. Happy to discuss if you see any problem with that approach though.

eliykat avatar Jan 17 '23 01:01 eliykat