You are viewing a plain text version of this content. The canonical link for it is here.
Posted to pr@jena.apache.org by "SimonBin (via GitHub)" <gi...@apache.org> on 2023/02/04 21:32:48 UTC

[GitHub] [jena] SimonBin opened a new pull request, #1746: GH-1745: fix plus sharing

SimonBin opened a new pull request, #1746:
URL: https://github.com/apache/jena/pull/1746

   GitHub issue resolved #1745
   
   Pull request Description: 
   
   Fix sharing of query string containing `+` with the fuseki yasqe UI
   
   @kinow maybe you can write a test for this?
   
   to test it manually:
   
   - put `+++++` in a query
   - click on the share button inside the query editor
   - paste that link in a new browser window
   - with the bug, the query editor only contains `     ` instead of `+++++`
   
   ----
   
    - [ ] Tests are included.
    - [ ] Documentation change and updates are provided for the [Apache Jena website](https://github.com/apache/jena-site/)
    - [ ] Commits have been squashed to remove intermediate development commit messages.
    - [ ] Key commit messages start with the issue number (GH-xxxx or JENA-xxxx)
   
   By submitting this pull request, I acknowledge that I am making a contribution to the Apache Software Foundation under the terms and conditions of the [Contributor's Agreement](https://www.apache.org/licenses/contributor-agreements.html).
   
   ----
   
   See the [Apache Jena "Contributing" guide](https://github.com/apache/jena/blob/main/CONTRIBUTING.md).
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: pr-unsubscribe@jena.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: pr-unsubscribe@jena.apache.org
For additional commands, e-mail: pr-help@jena.apache.org


[GitHub] [jena] afs merged pull request #1746: GH-1745: fix plus sharing

Posted by "afs (via GitHub)" <gi...@apache.org>.
afs merged PR #1746:
URL: https://github.com/apache/jena/pull/1746


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: pr-unsubscribe@jena.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: pr-unsubscribe@jena.apache.org
For additional commands, e-mail: pr-help@jena.apache.org


[GitHub] [jena] kinow commented on pull request #1746: GH-1745: fix plus sharing

Posted by "kinow (via GitHub)" <gi...@apache.org>.
kinow commented on PR #1746:
URL: https://github.com/apache/jena/pull/1746#issuecomment-1417237045

   Not a problem. I saw your invitation to join your repository and I've accepted it. Will finish testing it locally and push a single commit to your branch, probably in a few (~5 hours).


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: pr-unsubscribe@jena.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: pr-unsubscribe@jena.apache.org
For additional commands, e-mail: pr-help@jena.apache.org


[GitHub] [jena] kinow commented on a diff in pull request #1746: GH-1745: fix plus sharing

Posted by "kinow (via GitHub)" <gi...@apache.org>.
kinow commented on code in PR #1746:
URL: https://github.com/apache/jena/pull/1746#discussion_r1096731851


##########
jena-fuseki2/jena-fuseki-ui/src/utils/query.js:
##########
@@ -0,0 +1,54 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/*
+ * Utility functions for query components and views.
+ *
+ * Useful to separate code that can be easily tested without having to
+ * instantiate a complete component or view.
+ */
+
+import queryString from 'query-string'
+
+/**
+ * Create a shareable link using the value of the SPARQL query in the
+ * YASQE editor and compose a safe link to be used in the browser.
+ *
+ * Based on YASGUI code, but modified to avoid parsing the Vue Route query
+ * hash. Note that we cannot use `document.location.hash` since it could
+ * contain the ?query=... too. Instead, we must use Vue Route path value.
+ *
+ * The query is escaped with the same code as YASGUI.
+ *
+ * @param {string} query
+ * @param {string} path
+ * @return {string}
+ */
+export function createShareableLink (query, path) {

Review Comment:
   Moved this function out of the `Query.vue` Vue.js view, because it would be easier to test it that way instead of writing a complete e2e or unit test.



##########
jena-fuseki2/jena-fuseki-ui/src/utils/query.js:
##########
@@ -0,0 +1,54 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/*
+ * Utility functions for query components and views.
+ *
+ * Useful to separate code that can be easily tested without having to
+ * instantiate a complete component or view.
+ */
+
+import queryString from 'query-string'
+
+/**
+ * Create a shareable link using the value of the SPARQL query in the
+ * YASQE editor and compose a safe link to be used in the browser.
+ *
+ * Based on YASGUI code, but modified to avoid parsing the Vue Route query
+ * hash. Note that we cannot use `document.location.hash` since it could
+ * contain the ?query=... too. Instead, we must use Vue Route path value.
+ *
+ * The query is escaped with the same code as YASGUI.
+ *
+ * @param {string} query
+ * @param {string} path
+ * @return {string}
+ */
+export function createShareableLink (query, path) {

Review Comment:
   Also made it receive directly a query and a path, instead of tying it up with YASQE object. Then in the view we just create a curried function that extracts the query from YASQE, and hoists the path from Vue Router.



##########
jena-fuseki2/jena-fuseki-ui/tests/unit/components/serverstatus.vue.spec.js:
##########
@@ -33,7 +33,6 @@ describe('ServerStatus', () => {
         mocks: {
           $fusekiService: {
             async getServerStatus () {
-              console.log('Hola!')

Review Comment:
   Sorry! I had noticed these console log lines, but I thought I had intentionally written that somewhere... but searching it revealed I had simply forgotten to remove this debug line :bow: 



##########
jena-fuseki2/jena-fuseki-ui/src/utils/query.js:
##########
@@ -0,0 +1,54 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/*
+ * Utility functions for query components and views.
+ *
+ * Useful to separate code that can be easily tested without having to
+ * instantiate a complete component or view.
+ */
+
+import queryString from 'query-string'
+
+/**
+ * Create a shareable link using the value of the SPARQL query in the
+ * YASQE editor and compose a safe link to be used in the browser.
+ *
+ * Based on YASGUI code, but modified to avoid parsing the Vue Route query
+ * hash. Note that we cannot use `document.location.hash` since it could
+ * contain the ?query=... too. Instead, we must use Vue Route path value.
+ *
+ * The query is escaped with the same code as YASGUI.
+ *
+ * @param {string} query
+ * @param {string} path
+ * @return {string}
+ */
+export function createShareableLink (query, path) {
+  return (
+    document.location.protocol +
+    '//' +
+    document.location.host +
+    document.location.pathname +
+    document.location.search +
+    '#' +
+    path +
+    '?' +
+    // Same as YASGUI does, good idea to avoid security problems...
+    queryString.stringify({ query })

Review Comment:
   @SimonBin 's fix is here :point_up: 
   
   :clap: 



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: pr-unsubscribe@jena.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: pr-unsubscribe@jena.apache.org
For additional commands, e-mail: pr-help@jena.apache.org


[GitHub] [jena] kinow commented on pull request #1746: GH-1745: fix plus sharing

Posted by "kinow (via GitHub)" <gi...@apache.org>.
kinow commented on PR #1746:
URL: https://github.com/apache/jena/pull/1746#issuecomment-1416870724

   > `+const PREFIX = 'http://localhost:3000/#/'`
   
   I will mock the `document.location` calls to make sure these values are always consistent across environments. Also need to see if we can add a few more queries to the `const tests = []` array of tests (closest I know of a parametrized test in JS).


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: pr-unsubscribe@jena.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: pr-unsubscribe@jena.apache.org
For additional commands, e-mail: pr-help@jena.apache.org


[GitHub] [jena] SimonBin commented on pull request #1746: GH-1745: fix plus sharing

Posted by "SimonBin (via GitHub)" <gi...@apache.org>.
SimonBin commented on PR #1746:
URL: https://github.com/apache/jena/pull/1746#issuecomment-1417177008

   > I tried pushing changes to the branch in your fork, but GH rejected my commit
   
   so sad. This time (with the PR from my personal fork instead of Org), on the right side of this Pull Request "Allow edits by maintainers" is displayed and enabled, so I thought it should work


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: pr-unsubscribe@jena.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: pr-unsubscribe@jena.apache.org
For additional commands, e-mail: pr-help@jena.apache.org


[GitHub] [jena] kinow commented on pull request #1746: GH-1745: fix plus sharing

Posted by "kinow (via GitHub)" <gi...@apache.org>.
kinow commented on PR #1746:
URL: https://github.com/apache/jena/pull/1746#issuecomment-1418130059

   (asking @afs to review too as I think it'd be better as both @SimonBin and I have added code to this PR :+1: please :bow: )


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: pr-unsubscribe@jena.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: pr-unsubscribe@jena.apache.org
For additional commands, e-mail: pr-help@jena.apache.org