question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Handle case where user uploads image with empty title (whitespace)

See original GitHub issue

Summary:

Try uploading an image with an empty title(only spaces) and description. App crashes on clicking next.

Add System logs:

Error pid or pid not exist
2018-06-18 19:26:50.123 1821-1821/fr.free.nrw.commons.debug E/SpannableStringBuilder: SPAN_EXCLUSIVE_EXCLUSIVE spans cannot have a zero length
    SPAN_EXCLUSIVE_EXCLUSIVE spans cannot have a zero length
2018-06-18 19:26:50.545 1821-1821/fr.free.nrw.commons.debug E/SpannableStringBuilder: SPAN_EXCLUSIVE_EXCLUSIVE spans cannot have a zero length
    SPAN_EXCLUSIVE_EXCLUSIVE spans cannot have a zero length
2018-06-18 19:26:52.982 1821-1821/fr.free.nrw.commons.debug E/AndroidRuntime: FATAL EXCEPTION: main
    Process: fr.free.nrw.commons.debug, PID: 1821
    java.lang.StringIndexOutOfBoundsException: length=0; regionStart=0; regionLength=1
        at java.lang.String.substring(String.java:1931)
        at fr.free.nrw.commons.Utils.capitalize(Utils.java:79)
        at fr.free.nrw.commons.PageTitle.<init>(PageTitle.java:25)
        at fr.free.nrw.commons.Utils.makeThumbBaseUrl(Utils.java:54)
        at fr.free.nrw.commons.Media.getImageUrl(Media.java:173)
        at fr.free.nrw.commons.contributions.ContributionDao.toContentValues(ContributionDao.java:95)
        at fr.free.nrw.commons.contributions.ContributionDao.save(ContributionDao.java:62)
        at fr.free.nrw.commons.upload.UploadService.queue(UploadService.java:153)
        at fr.free.nrw.commons.upload.UploadController$2.onPostExecute(UploadController.java:201)
        at fr.free.nrw.commons.upload.UploadController$2.onPostExecute(UploadController.java:132)
        at android.os.AsyncTask.finish(AsyncTask.java:667)
        at android.os.AsyncTask.-wrap1(AsyncTask.java)
        at android.os.AsyncTask$InternalHandler.handleMessage(AsyncTask.java:684)
        at android.os.Handler.dispatchMessage(Handler.java:102)
        at android.os.Looper.loop(Looper.java:163)
        at android.app.ActivityThread.main(ActivityThread.java:6379)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:904)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:794)

Expected behavior:

App should gracefully handle empty values.

Observed behavior:

App crashes!

Device and Android version:

What make and model device (e.g., Samsung J7) did you encounter this on? What Android version (e.g., Android 4.0 Ice Cream Sandwich or Android 6.0 Marshmallow) are you running? Is it the stock version from the manufacturer or a custom ROM ?

Commons app version:

You can find this information by going to the navigation drawer in the app and tapping ‘About’

Screen-shots:

Can be created by pressing the Volume Down and Power Button at the same time on Android 4.0 and higher.

Would you like to work on the issue?

Please let us know whether you want to fix the issue by yourself. If not, anyone can get the issue assigned to them.

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:5 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
maskaravivekcommented, Jun 19, 2018

Yes, I agree with you @misaochan. That check was already present, it was just not checking for whitespaces.

Before the fix:

Empty title (Eg. “”) Title with whitespace(Eg. " ")
Toast message indicating that empty title is not allowed Crash

After the fix:

Empty title (Eg. “”) Title with whitespace(Eg. " ")
Toast message indicating that empty title is not allowed Toast message indicating that empty title is not allowed
0reactions
maskaravivekcommented, Jun 19, 2018

Yup this is fixed now. (Y)

Currently merged to the feature branch for 2.8.0.

Read more comments on GitHub >

github_iconTop Results From Across the Web

php, file upload to directory with "spaces" in title?
The files that I am uploading do have spaces and they work fine as long as the $playlist has no spaces, so the...
Read more >
How whitespace is handled by HTML, CSS, and in the DOM
In the case of HTML, whitespace is largely ignored — whitespace in between words is treated as a single character, and whitespace at...
Read more >
How to remove empty space from above and below a picture
Hi - I'm currently trying to upload a rectangular picture and the editor shows a lot of wasted space above and below the...
Read more >
How To Process Images in Node.js With Sharp - DigitalOcean
It's common for applications that handle user-uploaded content to process images. For example, if you're writing a web application that ...
Read more >
Images | Contentful
Contentful has a separate Images API that helps you add and retrieve image files in spaces, but also offers manipulation features.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found