Skip to content

Commit 7637c38

Browse files
author
Gaurav SinghaRoy
committed
fixed a bug in URI encode in ruby
1 parent 4c6b84d commit 7637c38

2 files changed

Lines changed: 7 additions & 2 deletions

File tree

app/controllers/query_controller.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@ def execute_sparql
2121
dataset = params[:dataset]
2222
query = params[:query]
2323
if !query.blank? && !dataset.blank?
24-
uri = get_uri("http://localhost:#{get_rdf2any_server_port}/rdf2any/v1.0/convert/json?dataset="+dataset+"&query="+query)
25-
response = HTTParty.get(uri)
24+
uri = get_uri("http://localhost:#{get_rdf2any_server_port}/rdf2any/v1.0/convert/json?dataset="+dataset+"&query="+uri_value_encode(query))
25+
response = HTTParty.get(uri)
2626

2727
if params[:pdf].blank?
2828
render :json => response.to_json

app/helpers/application_helper.rb

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
require 'open-uri'
12
module ApplicationHelper
23
def get_sparql_prefixes
34
prefix = ""
@@ -65,4 +66,8 @@ def get_variable_name_of_property(property_uri)
6566
variable_name = property_uri.split("/").last
6667
return variable_name.gsub(/[^[:alnum:]]/, "").underscore
6768
end
69+
70+
def uri_value_encode(str)
71+
URI::encode(str).gsub("\&","%26")
72+
end
6873
end

0 commit comments

Comments
 (0)