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

Deferred URL with apostrophe fails to load #39

Open
Kovus opened this issue Nov 2, 2020 · 0 comments
Open

Deferred URL with apostrophe fails to load #39

Kovus opened this issue Nov 2, 2020 · 0 comments

Comments

@Kovus
Copy link

Kovus commented Nov 2, 2020

I was attempting to scan through files to find ones with a particular property set, and ran into an error:

	 3: from /work/gitlab/experiments/sharepoint-label-scan/.bundle/ruby/2.6.0/gems/sharepoint-ruby-0.1.1/lib/sharepoint-properties.rb:27:in `block in add_property'
	 2: from /work/gitlab/experiments/sharepoint-label-scan/.bundle/ruby/2.6.0/gems/sharepoint-ruby-0.1.1/lib/sharepoint-properties.rb:67:in `get_property'
	 1: from /work/gitlab/experiments/sharepoint-label-scan/.bundle/ruby/2.6.0/gems/sharepoint-ruby-0.1.1/lib/sharepoint-properties.rb:83:in `get_deferred_property'
/work/gitlab/experiments/sharepoint-label-scan/.bundle/ruby/2.6.0/gems/sharepoint-ruby-0.1.1/lib/sharepoint-ruby.rb:86:in `query': The expression "Web/GetFileByServerRelativePath(decodedurl='/sites/CAD/UNITED STATES/more-path-data/CAD Backgrounds 4.26.2019/A18-Build Out-Floor Plan - PARTIAL FOURTH FLOOR PLAN - PART 'C'.dwg')/Properties" is not valid. (Sharepoint::SPException)

It seems that while this value does get properly url-encoded with %27 instead of a single apostrophe ', it doesn't seem to be what sharepoint wants. Apparently sharepoint wants two apostrophes '' instead of a single apostrophe.

While I think the proper fix is probably in sharepoint-ruby.rb (in #api_path), the simple fix I used was to change this in sharepoint-properties.rb:

# line 80-84
    def get_deferred_property property_name
      deferred_data = @data[property_name]['__deferred']
      uri           = deferred_data['uri'].gsub(/^http.*\/_api\/web\//i, '').gsub(/%27/, "''")
      @site.query :get, uri
    end

Though, I'm not sure deferred uri's are used anywhere else, so it might be considered reasonable.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant