Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 829835
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T03:56:42+00:00 2026-05-15T03:56:42+00:00

I am writing an application where users are required to show their photo, however

  • 0

I am writing an application where users are required to show their photo, however as my server resources are very limited I can not let them upload it to the server.

So I have three major questions:

1. How to properly validate photo URL? At least I can validate with regexp, however I need to check for file ending:

`validates_format_of :photo_url, :with => URI::regexp(%w(http https))`

2. Security issues? XSS?

Even I validate the picture at the moment of creation, hacker can replace image with malicious stuff anytime.

3. Maybe there are free asset stores with API?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-15T03:56:42+00:00Added an answer on May 15, 2026 at 3:56 am

    1. How to properly validate photo URL?

    You can use a plugin that validates the format of an URL or write it your self:

      validates_each :photo_url do |record, attr, value|
        begin
          uri = URI::parse(value)
          record.errors.add(nil, 'Sorry, you may only use http/https links') if (uri.class.to_s =~ /URI::HTTPS?/).nil?
          record.errors.add(nil, 'The url must point to a picture') unless value =~ /\.(png|jpg|jpeg)$/i
        rescue URI::InvalidURIError
          record.errors.add(nil, 'The format of the url is not valid')
        end
      end
    

    2. Security issues? XSS?

    There aren’t any outstanding security issues as long as you escape the text.
    <%=h image_tag obj.photo_url %> is safe.
    Take in mind, that the user can still use a 100MB image that will slow down every visitor.

    3. Maybe there are free asset stores with API?

    There aren’t any that I know of, but rackspace cloud, amazon s3 hosting is pretty cheap.
    Some image upload plugins have support for these two, so you’ll at least save some time.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm writing a web application where users can submit pictures, videos, and descriptons of
I'm writing a web application with Django where users can upload files with statistical
i'm writing application like social network where in my application can show status update
I'm writing an ASP.NET application that requires users to log on to a server
I'm writing an application wherein users will sometimes make orders through it. I want
I'm writing an application where users enter some details into an SQLite Database. I
I'm writing an application that will add users to Active Directory. I'm trying to
I am writing an application that helps book exchange between users. I am using
I am writing an application which is going to allows users to change the
Part of an application I'm writing allows for users to upload images which I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.