Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Safe url naming #304

Closed
wants to merge 1 commit into from
Closed

Safe url naming #304

wants to merge 1 commit into from

Conversation

mbogh
Copy link
Contributor

@mbogh mbogh commented Sep 22, 2015

My take on #146

Requires realm/jazzy-integration-specs#4 to pass build

@mbogh mbogh changed the title [WIP] Safe url naming Safe url naming Sep 22, 2015
@@ -28,5 +30,9 @@ class SourceDeclaration
def overview
"#{abstract}\n\n#{discussion}".strip
end

def filename
FilenameCleaner.sanitize("#{name}")
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No need for string interpolation

@segiddins
Copy link
Collaborator

That gem seems to bring in a bunch of dependencies... Are we sure active support doesn't just have a method for this we could use?

@mbogh
Copy link
Contributor Author

mbogh commented Sep 22, 2015

As far as I have read, there is no built-in way of escaping strings so they are safe for the filesystem.
"All" filename_cleaner does is applying some regexes.

url = "init(baseURL:sessionConfig:requestSerializer:responseSerializer:)"
url.gsub(/[^\w\.]/, '')
 => "initbaseURLsessionConfigrequestSerializerresponseSerializer"

@mbogh
Copy link
Contributor Author

mbogh commented Sep 26, 2015

@segiddins do you have an opinion on the above?

@segiddins
Copy link
Collaborator

sure, using file-cleaner is fine if @jpsim is ok with it

@mbogh
Copy link
Contributor Author

mbogh commented Sep 26, 2015

Seems that file-cleaner does not copy the input and hence changes the input.

head :001 > require "filename_cleaner"
 => true 
head :002 > name = "Global Variables"
 => "Global Variables" 
head :003 > new_name = FilenameCleaner.sanitize(name, '_', false)
 => "Global_Variables" 
head :004 > name
 => "Global_Variables"

I'm not that familiar with Ruby but it seems odd to me that I'm responsible for sending in a copy.

@jpsim
Copy link
Collaborator

jpsim commented Oct 5, 2015

Unless I'm missing something, it does seem like URI::escape is a preferable solution

@mbogh mbogh closed this Oct 7, 2015
@mbogh mbogh deleted the safe-urls branch October 7, 2015 18:55
@pigeondotdev pigeondotdev modified the milestone: The Past Nov 22, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants