expo-clipboard 4.8.0 → 5.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -10,6 +10,16 @@
10
10
 
11
11
  ### 💡 Others
12
12
 
13
+ ## 5.0.1 — 2023-12-19
14
+
15
+ _This version does not introduce any user-facing changes._
16
+
17
+ ## 5.0.0 — 2023-12-12
18
+
19
+ ### 🐛 Bug fixes
20
+
21
+ - [Android] Fix path traversal vulnerability in `getFileForUri` function. ([#25549](https://github.com/expo/expo/pull/25549) by [@behenate](https://github.com/behenate))
22
+
13
23
  ## 4.8.0 — 2023-11-14
14
24
 
15
25
  ### 🛠 Breaking changes
@@ -3,7 +3,7 @@ apply plugin: 'kotlin-android'
3
3
  apply plugin: 'maven-publish'
4
4
 
5
5
  group = 'host.exp.exponent'
6
- version = '4.8.0'
6
+ version = '5.0.1'
7
7
 
8
8
  def expoModulesCorePlugin = new File(project(":expo-modules-core").projectDir.absolutePath, "ExpoModulesCorePlugin.gradle")
9
9
  if (expoModulesCorePlugin.exists()) {
@@ -94,7 +94,7 @@ android {
94
94
  namespace "expo.modules.clipboard"
95
95
  defaultConfig {
96
96
  versionCode 3
97
- versionName '4.8.0'
97
+ versionName '5.0.1'
98
98
  }
99
99
  }
100
100
 
@@ -17,7 +17,7 @@ internal class CopyFailureException(cause: Throwable?, kind: String = "item") :
17
17
  internal class InvalidImageException(image: String, cause: Throwable?) :
18
18
  CodedException(
19
19
  "Invalid base64 image: ${
20
- image.run { substring(0, minOf(length, 32)) + if (length > 32) "..." else ""}
20
+ image.run { substring(0, minOf(length, 32)) + if (length > 32) "..." else ""}
21
21
  }",
22
22
  cause
23
23
  )
@@ -93,6 +93,7 @@ class ClipboardFileProvider : ContentProvider() {
93
93
  columns[i] = OpenableColumns.DISPLAY_NAME
94
94
  values[i++] = file.name
95
95
  }
96
+
96
97
  OpenableColumns.SIZE -> {
97
98
  columns[i] = OpenableColumns.SIZE
98
99
  values[i++] = file.length()
@@ -223,10 +224,12 @@ class ClipboardFileProvider : ContentProvider() {
223
224
  val externalFilesDirs: Array<File> = context.getExternalFilesDirs(null)
224
225
  externalFilesDirs.takeIf { it.isNotEmpty() }?.let { it[0] }
225
226
  }
227
+
226
228
  TAG_EXTERNAL_CACHE -> {
227
229
  val externalCacheDirs: Array<File> = context.externalCacheDirs
228
230
  externalCacheDirs.takeIf { it.isNotEmpty() }?.let { it[0] }
229
231
  }
232
+
230
233
  else -> null
231
234
  }
232
235
 
@@ -309,9 +312,9 @@ class ClipboardFileProvider : ContentProvider() {
309
312
  for (root in roots.entries) {
310
313
  val rootPath = root.value.path
311
314
  if (path.startsWith(rootPath) && (
312
- mostSpecific == null ||
313
- rootPath.length > mostSpecific.value.path.length
314
- )
315
+ mostSpecific == null ||
316
+ rootPath.length > mostSpecific.value.path.length
317
+ )
315
318
  ) {
316
319
  mostSpecific = root
317
320
  }
@@ -348,7 +351,7 @@ class ClipboardFileProvider : ContentProvider() {
348
351
  } catch (e: IOException) {
349
352
  throw java.lang.IllegalArgumentException("Failed to resolve canonical path for $file")
350
353
  }
351
- if (!file.path.startsWith(root.path)) {
354
+ if (!file.startsWith(root)) {
352
355
  throw SecurityException("Resolved path jumped beyond configured root")
353
356
  }
354
357
  return file
@@ -32,7 +32,7 @@ data class ImageResult(
32
32
  "size" to bundleOf(
33
33
  "width" to width,
34
34
  "height" to height
35
- ),
35
+ )
36
36
  )
37
37
  }
38
38
  // endregion
@@ -93,7 +93,7 @@ internal suspend fun imageFromContentUri(
93
93
  internal suspend fun clipDataFromBase64Image(
94
94
  context: Context,
95
95
  base64Image: String,
96
- clipboardCacheDir: File,
96
+ clipboardCacheDir: File
97
97
  ): ClipData {
98
98
  // 1. Get bitmap from base64 string
99
99
  val bitmap = bitmapFromBase64String(base64Image)
@@ -24,7 +24,8 @@ internal class SetStringOptions : Record {
24
24
  }
25
25
 
26
26
  internal enum class ImageFormat(val jsName: String) : Enumerable {
27
- JPG("jpeg"), PNG("png");
27
+ JPG("jpeg"),
28
+ PNG("png");
28
29
 
29
30
  val compressFormat: Bitmap.CompressFormat
30
31
  get() = when (this) {
@@ -6,7 +6,7 @@ import UIKit
6
6
  import MobileCoreServices
7
7
 
8
8
  class ClipboardModuleSpec: ExpoSpec {
9
- override func spec() {
9
+ override class func spec() {
10
10
  let appContext = AppContext.create()
11
11
  let holder = ModuleHolder(appContext: appContext, module: ClipboardModule(appContext: appContext))
12
12
 
@@ -24,7 +24,9 @@ class ClipboardModuleSpec: ExpoSpec {
24
24
  func expectModuleFunctionThrows<T>(_ functionName: String, args: [Any], exception: T.Type) where T: Exception {
25
25
  waitUntil(timeout: .seconds(3)) { done in
26
26
  holder.call(function: functionName, args: args) { result in
27
- expect(result).to(beFailure(exception: exception))
27
+ expect(result).to(beFailure { error in
28
+ expect(error.rootCause is T).to(beTrue())
29
+ })
28
30
  done()
29
31
  }
30
32
  }
@@ -304,16 +306,3 @@ class ClipboardModuleSpec: ExpoSpec {
304
306
  }
305
307
  }
306
308
  }
307
-
308
- // TODO: (barthap) Replace this with built-in beFailure() when upgraded to Nimble 10.0
309
- func beFailure<Success, Failure, T: Exception>(exception: T.Type) -> Nimble.Predicate<Result<Success, Failure>> {
310
- return Predicate.simple("be \(exception)") { actualExpression in
311
- guard let actual = try actualExpression.evaluate(),
312
- case let .failure(error) = actual,
313
- (error as? Exception)?.rootCause is T
314
- else {
315
- return .doesNotMatch
316
- }
317
- return .matches
318
- }
319
- }
@@ -14,7 +14,10 @@ class MockNSAttributedString: NSAttributedString {
14
14
  }
15
15
 
16
16
  override var rtfData: Data? {
17
- return try? self.data(from: NSRange(location: 0, length: self.length))
17
+ return try? self.data(
18
+ from: NSRange(location: 0, length: self.length),
19
+ documentAttributes: [.documentType: NSAttributedString.DocumentType.rtf]
20
+ )
18
21
  }
19
22
 
20
23
  override var htmlString: String? {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "expo-clipboard",
3
- "version": "4.8.0",
3
+ "version": "5.0.1",
4
4
  "description": "ExpoClipboard standalone module",
5
5
  "main": "build/Clipboard.js",
6
6
  "types": "build/Clipboard.d.ts",
@@ -39,5 +39,5 @@
39
39
  "jest": {
40
40
  "preset": "expo-module-scripts/universal"
41
41
  },
42
- "gitHead": "3142a086578deffd8704a8f1b6f0f661527d836c"
42
+ "gitHead": "43f1b4f8a5a9bca649e4e7ca6e4155482a162431"
43
43
  }